Fetching Server Data – Intro
$http in AngularJS is the service that assists us with fetching data from remote http services.
The simple way for using it is when you need data in a controller, then issue the $http call and use the data. This way works 100%, but as always our application is getting bigger…
If you do not manage your services you’ll find yourself writing the same http call dozens of times. If you want to avoid this (and you do!), then you can use AngularJS Services.
There are several ways for solving this problem via AngularJS Services. In this post, I’ll describe 2 ways for solving the reuse of $http.
1. One service endpoint for managing the entire http calls in our application.
2. One service for every model you have in your application.
This mean that you have several services.