it:ad:angular.js:howto:understand_values_factories_services_providers

IT:AD:Angular.JS:HowTo:Understand/Values, Factories, Services, Providers

Angular has a couple of different ways of providing data:

  • Constants
  • Values
  • Factories
  • Services
  • Providers
    They're really all just convention based ways of persisting data, or methods that return data, in the module, so that they can be DI'ed into things that need the data (eg: Controllers).

A Constant or Value is nothing more than a Key/Value defined at a module level, that can then be Dependency injected into controllers, etc.

Values:

Constants:

Factories are dynamic Values, in as much that they are just like Values, except that they are methods:

Services will turn out to be the most used classes – at least in my apps.

Finally, providers.

Providers are much like Services, except where those are singletons, Providers are more like configurable service factories:

So if providers is more or less the same as services, bar more complicated factory creation, why bother? Because it can be made confirable:

  • /home/skysigal/public_html/data/pages/it/ad/angular.js/howto/understand_values_factories_services_providers.txt
  • Last modified: 2023/11/04 03:37
  • by 127.0.0.1