Reputation: 1904
In Angular, when using $resource, how do you update a list of objects after making a post request? If you save or update an individual object, you'd then want the the full list to reflect the change of data. Is this handled by $resource or do you have to implement this on your own?
Upvotes: 0
Views: 388
Reputation: 5435
you need to do it after the update succeeds. how you do it it depends on your service return value and your approach
using the callback approach
var R=$resource('searches/:id',null,{
'update': { method:'PUT' }
});
R.delete({id:id},function(){
$scope.searches.splice(searchIdxById(id),1);
$scope.saved=false;
});
R.update({id:id},{},function(){
//success
},function(){
//fails
});
some reading https://docs.angularjs.org/api/ngResource/service/$resource
Upvotes: 1