Reputation: 4886
I am trying to implement CRUD using $resource, i am not finding any issues in POST, PUT and GET. But on delete method the params are getting passed as query string.
My service:
service.Assigndepart = $resource(CONFIG.wsurl + '/employee/assign/depart',null, {
update: {
method: 'PUT'
},
remove:{
method: 'DELETE'
}
});
And calling my controller as
Assigndepart.remove(params, function(success), function(error));
my url is passing with query string as ?employee=1234&depart=456. Can some help on this
Upvotes: 1
Views: 588
Reputation: 15237
According to the Angular $resource documentation the action methods without a body need to be invoked with the following parameters:
Resource.action([parameters], postData, [success], [error])
So you are passing your postData
as params for your DELETE action. The correct call on your controller will be:
Assigndepart.remove({}, params, function(success), function(error));
Upvotes: 0
Reputation: 97
See basically if you get into the Html apis in form tag for method type what you will see is only support for get and post method, which indicates that with post and get we can do everything we want all of the others are just good conventions and some code optimizations(like put method).The delete method is just similar to the get method which always includes the parameters as its param there is nothing you can do about it.if you want to remove that you have to use the structure of post or put requests only or you can still use the delete method with some encryption and decryption at both ends i.e. application server and front end.
Upvotes: 1