my js code:
camListApp.controller("Hello", function($scope, $http, $uibModal){
$scope.del=function(data){
var result=confirm('are you sure?');
if(result==true){
var index=getSelectedIndex(data);
$scope.records.splice(index, 1);
}
};
function getSelectedIndex(data) {
for (var i =0; i<$scope.records.length; i++)
if($scope.records[i].data==data)
return i;
return -1;
}
Html code:
<td><button class="btn" ng-click="del(record.filename)">Delete</button></td>
My json data:
[{"cameraid":"000000001","timestamp":"2016-07-09 10:06","filename":"c037731fc2256177ba29c7893caacf04","locationid":"Bedok01"}
{"cameraid":"000000003","timestamp":"2016-07-13 11:35","filename":"4fd2413d30073b4b6a5cacbb8b7c1965","locationid":"Bedok01"}
{"cameraid":"000000003","timestamp":"2016-07-13 14:41","filename":"6b6b62948eb679efeb650d609c85b7aa","locationid":"Bedok01"}
How can i do a delete function on angularjs and when the button is clicked and at the same time mongodb also remove the data. Anybody can help?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…