Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...