Send Request Body on $resource

后端 未结 2 1667
名媛妹妹
名媛妹妹 2020-12-13 17:57

I take a look on Angular API for $resource and I didn\'t find some way to send a Request Body to a RESTful service.

I know this is possible using $http

相关标签:
2条回答
  • 2020-12-13 18:45

    As long as the action supports a body message (e.g. POST, but not GET), you can pass a data parameter to the action method of your resource, which will be sent in the body of the request:

    yourResource.save(yourData)
    

    Example: http://jsfiddle.net/N3NXK/1/

    0 讨论(0)
  • 2020-12-13 18:53

    Building on @gargc's answer, you can pass parameters and a body to a resource's method:

    myResource.save({ param: myParam }, myObject);
    
    0 讨论(0)
提交回复
热议问题