加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 发送请求Body on $resource

发布时间:2020-12-17 08:43:09 所属栏目:安全 来源:网络整理
导读:我看一下 Angular API的$资源,我没有找到一些方法发送一个请求体到RESTful服务。 我知道这是可能使用$ http方法,如here,所以,是否也可以使用$ resource? 显然这是$ resource的选项。 action – {string} – The name of action. This name becomes the
我看一下 Angular API的$资源,我没有找到一些方法发送一个请求体到RESTful服务。

我知道这是可能使用$ http方法,如here,所以,是否也可以使用$ resource?

显然这是$ resource的选项。

action – {string} – The name of action. This name becomes the name of the method on your resource object.

method – {string} – HTTP request
method. Valid methods are: GET,POST,PUT,DELETE,and JSONP

params
{object=} – Optional set of pre-bound parameters for this action.

isArray – {boolean=} – If true then the returned object for this
action is an array,see returns section.

目前,我没有找到任何方式发送包含JSON对象的请求有效内容。

只要操作支持正文消息(例如POST,而不是GET),您就可以将数据参数传递到资源的action方法,该方法将在请求的正文中发送:
yourResource.save(yourData)

示例:http://jsfiddle.net/N3NXK/1/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读