Angular.js delete resource with parameter

后端 未结 4 1669
醉酒成梦
醉酒成梦 2021-02-01 17:52

My rest api accpets DELETE requests to the following url

/api/users/{slug}

So by sending delete to a specified user (slug) the user would be de

4条回答
  •  情深已故
    2021-02-01 17:54

    If you want to delete a model, there's no need to add params (params does not work for DELETE anyway):

    $resource('/users/:id').delete({id: user.id}, function(res) {
      ...
    })
    

    or

    $resource('/users/:role/:id').delete({role: 'visitor', id: user.id});
    

    I'm not sure if it's a bug of ngResource.

提交回复
热议问题