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,603
  • 14
  • 24

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
  • 678,734
  • 91
  • 1,224
  • 1,255