Looking for angularjs Answers? Try Ask4KnowledgeBase
Looking for angularjs Keywords? Try Ask4Keywords

AngularJSProviders


Syntax

  • constant(name, value);
  • value(name, value);
  • factory(name, $getFn);
  • service(name, constructor);
  • provider(name, provider);

Remarks

Providers are singleton objects that can be injected, for example, into other services, controllers and directives. All providers are registered using different "recipes", where Provider is the most flexible one. All possible recipes are:

  • Constant
  • Value
  • Factory
  • Service
  • Provider

Services, Factories and Providers are all lazy initialized, component is initialized only if application depends on it.

Decorators are closely related to Providers. Decorators are used to intercept service or factory creation in order to change it's behavior or override (parts of) it.