Angular.js Services

In the angular.js all the services are written in the JavaScript to perform the specific action and can easily reuse in the application.


The angular.js supports built-in and allows users to create services in their application.



  • All built-in angular.js services start with $ symbol.
  • Services provide the function to communicate data across the controllers in a reliable way.
  • Services help to organize and share members and functions across the application.
  • Services provide the function to have data across the application.


The angular.js services are lazy instantiated and singleton which Angular only creates instance of a service when an application component depends on it.


The following are the some of the built-in services that use in the angular.js application.


$log $routeProvider $cookies
$timeout $locale $q
$http $resource $routeParams
$controller  $compile  $window 
$templateRequest  $httpBackend  $rootElement 
$sceDelegate  $filter  $animate 
$exceptionHandler  $anchorScroll  $httpParamSerializer 

Additionally, we can also create our own custom services based on the requirement.  We will explain how to create and use the services in the angularJS with an example in next tutorial.

AngularJS - Register Services

We can create or register services in the angularJS using below methods

  • Using the constant() method
  • Using the provider() method
  • Using the service() method
  • Using the factory() method
  • Using the value() method

Using the factory() method syntax


Following is the basic syntax for using Factory service.  


return factoryObj;

You will learn all about the http services with example in Angular in the next chapter.