AngularJS Providers

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any AngularJS Question?