1

I'm learning AngularJS and I noticed that A Factory is a short-hand for a Provider. Can you tell me specific scenarios where I should/must use a Provider instead of a Factory? The codes stays much more readable if use a Factory method instead of the provider.

Mário
  • 1,593
  • 13
  • 23

1 Answers1

1

A Provider is necessary when the provider itself has methods that you want the user of your service to call during the configuration phase of the application.

See for example the $location service: it has a $locationProvider which allows setting it to html5 mode, while the application is being configured (using module.config()).

JB Nizet
  • 657,433
  • 87
  • 1,179
  • 1,226