Sunday, September 3, 2017

Custom Services in AngularJS


There are 5 different ways to create services in AngularJS.
  • Value:
    1. In AngularJS, value is a simple object. It can be a number, string or JavaScript object. It is used to pass values in factories, services or controllers during run and config phase. Value cannot be injected into configurations, but it can be intercepted by decorator means that the value can be changed. Read More
  • Service:
    1. It is used to organize and share data and functions across the application.
    2. Service is a constructor function. Read More
  • Factory:
    1. A factory is a simple Javascript function which allows you to add some logic before creating the object. It returns the created object.
    2. This is a singleton object . Read More
  • Provider:
    1. Use it when you want to configure something and pass it to .config of your module. 
    2. Use it to create configurable factories. You can customise such factories during bootstrap
  • Constant:
    1. A constant can be injected anywhere.
    2. A constant cannot be intercepted by a decorator that means that the value of a constant should never be changed. Read More

No comments:

Post a Comment