ric*_*wol 9 angularjs angular-resource
我有一个angularJS $资源:
$resource("http://localhost:3000/:id",{
id: '@id'
},
{
get: {
method:'GET',
isArray: false
},
foo: {
method:'POST',
url: 'http://localhost:3000/:id/foo',
isArray: false
}
});
Run Code Online (Sandbox Code Playgroud)
现在,如果我打电话:
User.foo({id:'123', anotherParam: 'bar'});
Run Code Online (Sandbox Code Playgroud)
这会导致调用URL" http:// localhost:3000/foo "并将id和anotherParam参数作为POST字段传递.
我实际上希望它调用' http:// localhost: 3000/123 / foo '并仅将anotherParam参数作为POST字段传递.
如何让id参数正常运行?
DTi*_*ing 20
https://docs.angularjs.org/api/ngResource/service/$resource
非GET"类"操作:Resource.action([parameters],postData,[success],[error])
你需要这样做:
User.foo({id:'123', anotherParam: 'bar'}, <post data object>);
Run Code Online (Sandbox Code Playgroud)
使用单个参数调用函数时.它假定可选参数不存在并将其作为postData发送.
| 归档时间: |
|
| 查看次数: |
10670 次 |
| 最近记录: |