Skip to content

Instantly share code, notes, and snippets.

@anjanawijesundara
Created April 13, 2015 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjanawijesundara/88197b313f8c12bb1711 to your computer and use it in GitHub Desktop.
Save anjanawijesundara/88197b313f8c12bb1711 to your computer and use it in GitHub Desktop.
app.js Part Four
app.controller('CustomerEditControler',[
'$scope','$http','$location','$routeParams',
function ($scope, $http, $location, $routeParams) {
var id = $routeParams.id;
$scope.activePath = null;
$http.get('api/Customers/'+id).success(function(data) {
$scope.CustomerDetail = data;
});
$scope.Update_Customer = function(customer) {
$http.put('api/Customers/'+id, customer).success(function(data) {
$scope.CustomerDetail = data;
$scope.activePath = $location.path('/');
});
};
$scope.Delete_Customer = function(customer) {
console.log(customer);
var deleteCustomer = confirm('Are you absolutely sure you want to delete?');
if (deleteCustomer) {
$http.delete('api/Customers/'+customer.id);
$scope.activePath = $location.path('/');
}
};
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment