$resource, get和query之间有什么区别?

时间:2022-02-16 13:21:24

The documentation doesn't seem to specify: http://docs.angularjs.org/api/ngResource.$resource

文档似乎没有指定:http://docs.angularjs.org/api/ngResource.$resource

1 个解决方案

#1


67  

The main difference lies in query having isArray: true :

主要区别在于查询具有isArray: true:

'get'  :  {method:'GET'},
'query':  {method:'GET', isArray:true}

This means you would use get when requesting a single object, and query when requesting a collection. For example:

这意味着在请求单个对象时使用get,在请求集合时使用查询。例如:

Users.get({userId:123}); // returns a single user
Users.query(); // returns a collection of all users.

#1


67  

The main difference lies in query having isArray: true :

主要区别在于查询具有isArray: true:

'get'  :  {method:'GET'},
'query':  {method:'GET', isArray:true}

This means you would use get when requesting a single object, and query when requesting a collection. For example:

这意味着在请求单个对象时使用get,在请求集合时使用查询。例如:

Users.get({userId:123}); // returns a single user
Users.query(); // returns a collection of all users.