Angularjs ngResource“@id” [英] Angularjs ngResource '@id'
本文介绍了Angularjs ngResource“@id”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个快速的问题。在角JS那里(如哪个对象)请问'@id'来自于从一个Rails应用程序下面的一段code的?
I have a quick question. In angular js where (like which object) does the '@id' come from in the following piece of code from a rails app?
var User = $resource("/users/:id", {id: '@id'});
我知道它设置默认的ID。
I know it sets the default id.
感谢
推荐答案
从AngularJs 文档
From the AngularJs documentation:
如果参数值是与@ pfixed则该值$ P $
参数从数据对象中提取(有用非GET
操作)。
"If the parameter value is prefixed with @ then the value of that parameter is extracted from the data object (useful for non-GET operations)."
这意味着,调用非GET操作,如帖子的时候,你可以通过ID作为对象,你在调用包括数据的领域之一。
This means that when calling a non-GET operation, like POST, you can pass the id as one of the fields of the data object you include in the call.
这篇关于Angularjs ngResource“@id”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文