0

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 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Could you point me in the direction of any codes examples so I can get a sense of how to do that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.