top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

    Get Free Article Updates

Facebook Login
Site Registration
Print Preview

What are the services in AngularJS?

+1 vote
45 views

Services are one of the most important concepts in AngularJS. In general services are functions that are responsible for specific tasks in an application. AngularJS services are designed based on two principles.

  1. Lazily instantiated 

    Angular only instantiates a service when an application component depends on it using dependency injection for making the Angular codes robust and less error prone.
     
  2. Singletons

    Each component is dependent on a service that gets a reference to the single instance generated by the service factory.

    AngularJS provides many built in services, for example, $http, $route, $window, $location and so on. Each service is responsible for a specific task, for example, $http is used to make an Ajax call to get the server data. $route defines the routing information and so on. Builtin services are always prefixed with the $ symbol.

AngularJS internal services

AngularJS internally provides many services that we can use in our application. $http is one example. There are other useful services, such as $route, $window, $location and so on. Some of the commonly used services in any AngularJS applications are listed below.

  • $window Provide a reference to a DOM object.
  • $Location Provides reference to the browser location.
  • $timeout Provides a reference to window.settimeout function.
  • $Log Used for logging.
  • $sanitize Used to avoid script injections and display raw HTML in page.
  • $Rootscope Used for scope hierarchy manipulation.
  • $Route Used to display browser based path in browser URL.
  • $Filter Used for providing filter access.
  • $resource Used to work with Restful API.
  • $document Used to access the window. Document object.
  • $exceptionHandler Used for handling exceptions.
  • $q: Provides a promise object.details
posted Sep 28 by Shivaranjini

  Promote This Article
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...