AngularJS Services

In AngularJS you can make your own service, or use one of the many built-in services.

In AngularJS, a service is a function, or object, that is available for, and limited to, your AngularJS application. AngularJS has about 30 built-in services. One of them is the $location service. The $location service has methods which return information about the location of the current web page.

For many services, like the $location service, it seems like you could use objects that are already in the DOM, like the window.location object, and you could, but it would have some limitations, at least for your AngularJS application. AngularJS constantly supervises your application, and for it to handle changes and events properly, AngularJS prefers that you use the $location service instead of the window.location object.

The $http service is one of the most common used services in AngularJS applications. The service makes a request to the server, and lets your application handle the response.

The $timeout service is AngularJS’ version of the window.setTimeout function. The $interval service is AngularJS’ version of the window.setInterval function.

Leave a comment

Your email address will not be published. Required fields are marked *