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?
1 Answer
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
SOME CODE
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
1 Comment
inperspective
Could you point me in the direction of any codes examples so I can get a sense of how to do that?