Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$resource, what's the difference between get and query?

Tags:

angularjs

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

like image 676
Robert Christ Avatar asked Oct 18 '13 17:10

Robert Christ


1 Answers

The main difference lies in query having 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:

Users.get({userId:123}); // returns a single user
Users.query(); // returns a collection of all users.
like image 154
xbonez Avatar answered Oct 16 '22 10:10

xbonez