Reputation: 10551
I'm trying to create an update function in an angular controller:
$scope.update = function(product){
product.$save();
$scope.cancelEdit();
}
My backend has two routes for updating a resource:
PATCH /products/:id(.:format)
PUT /products/:id(.:format)
However, I can't access either of these using $resource
! According to the docs, I can either use these functions to send requests with certain http verbs:
{ 'get': {method:'GET'},
'save': {method:'POST'},
'query': {method:'GET', isArray:true},
'remove': {method:'DELETE'},
'delete': {method:'DELETE'} };
So how am I meant to send a PATCH or PUT request?
HOW SHOULD I CONFIGURE THIS IN MY APP CENTRALLY?
Upvotes: 0
Views: 393
Reputation: 191779
These are just the defaults, but per the documentation for $resource
you can define your own actions.
$resource(url, paramDefaults, {
put: {method: 'PUT'},
patch: {method: 'PATCH'},
});
Upvotes: 2