When calling $save on an ngResource, is it possible to POST only the edited fields rather than POSTing the entire model each time?
var User = $resource('http://example.com/user/123/');
User.get(function(user) {
user.name="John Smith";
user.$save();
// What I *want* -> POST: /user/123/ {name:'John Smith'}
// What currently happens -> POST: /user/123/ {name:'John Smith', age: 72, location: 'New York', noOfChildren: 5}
});
No, it’s not possible, at least not on instances, see http://docs.angularjs.org/api/ngResource.$resource
So, it’s only possible by passing the data to save to the “static” save method, ie
User.save. Something like this:Whether this works out for you will probably depend on what you’re going to do with the
userinstance.