I am taking two different classes on Udemy and started with angular2 so I understand ng2's service approach. Now I'm learning angular 1, can someone clarify angular1's $http service for me? Do I use it in a custom service? or is it the service that goes within a controller? Basically what's the best practice for a non crud $http GET of json
-
You can do either but I think most people would recommend that you use it in a custom service.jbrown– jbrown2016-07-20 00:39:45 +00:00Commented Jul 20, 2016 at 0:39
-
So do I inject the HTTP service object? all the custom service examples I see don't have dependency injection, they just look like normal functionsSD Dev– SD Dev2016-07-20 01:13:15 +00:00Commented Jul 20, 2016 at 1:13
-
Yes, inject $http where you need to use it....service, controller or directive etccharlietfl– charlietfl2016-07-20 02:46:20 +00:00Commented Jul 20, 2016 at 2:46
Add a comment
|