The $resource
is asyn process and returns promise1.
From your code:
IndustrialistFactory.delete({id: id, industrialistId: industrialistId });
$scope.industrialists= IndustrialistsFactory.query({},{id: id});
You try to delete element and immediately after load new object.
Try to run $scope.industrialists= IndustrialistsFactory.query({},{id: id});
only after you got callback that element was deleted.
It should be something like:
IndustrialistFactory.delete({id: id, industrialistId: industrialistId }).
.$promise.then(
//success
function( value ){
$scope.industrialists= IndustrialistsFactory.query({},{id: id});
},
//error
function( error ){
alert(error);
}
)
What is promise:1
A promise represents a future value, usually a future result of an asynchronous operation, and allows us to define what will happen once this value becomes available, or when an error occurs.