The Angular way would be to create a service which returns a $resource.

$resource a higher level abstraction on $http for REST interfaces
https://docs.angularjs.org/api/ngResource/service/$resource

As mentioned by others the benefit are the following: 
1.  You can reuse it in many controllers
2.  More ease of unit testing

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to