Some sentences I wish I had read when I started using angular.
A provider is a function that gets
new
ed. And can be injected into a config block in that state.When its time to be used (ie. injected elsewhere)
$get
is called and the return value from that is your provider.A service is a function that gets
new
ed and thats your service.A factory is a function that gets
new
ed and executed. Its return value is your factory.
The three different terms are just to differentiate the method in which they're created.
Some good uses for each:
- provider: As a configuration for an angular library or api service
- service: a 'class like' object. Maybe for storing shared application data
- factory: a data retrieval object that handles getting and saving of data.. maybe into your service.