<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Processing $http.delete() response in service</title>
<script src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
<script>
var app = angular.module('myServiceApp', []);
app.controller('myServiceCtrl', function($scope) {
$scope.lblMsg = null; //default
$scope.users = [{
name: "Anil Singh",
email: 'anil.singh@gmail.com'
}, {
name: "Dilip Singh",
email: 'dilip@gmail.com'
}];
$scope.deleteRow = function(id) {
var data = {
Id: id
};
alert(JSON.stringify(id));
//Call the delete services
$http.delete('htpp://localhost:8080/api/users/delete', JSON.stringify(data)).then(function(rest, status) {
if (status) {
if (rest.data)
$scope.lblMsg = "Delete row submit successfully!";
} else {
$scope.lblMsg = "faild to delete!";
}
});
};
});
</script>
</head>
<body ng-app="myServiceApp">
<div ng-controller="myServiceCtrl">
<div ng-repeat="row in users">
<div>{{row.name}} | {{row.email}}</div>
<a href="#" ng-click="deleteRow($index)">Delete</a>
<br> Output Message : {{ $scope.lblMsg}}
</div>
</div>
</body>
</html>
// Code goes here
/* Styles go here */