Angularjs ngResource“@id”Angularjs、ngResource、id

2023-09-13 04:11:48 作者:软软的唇

我有一个快速的问题。在角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.