Angularjs ngResource '@id'

会有一股神秘感。 提交于 2020-01-12 08:44:31

问题


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'});

I know it sets the default id.

Thanks


回答1:


From the AngularJs documentation:

"If the parameter value is prefixed with @ then the value of that parameter is extracted from the data object (useful for non-GET operations)."

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.



来源:https://stackoverflow.com/questions/15059764/angularjs-ngresource-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!