Edit 04/15 The answers I've gotten so far explain the difference between service/factory/ and provider, but that doesn't really get at what I'm confused about. AngularJS documentation asserts that all three are essentially the same code "under the hood". But if that's the case, why can I only pass a "provider" into a configuration block, as opposed to a "factory"?
Original Question:
According to the documentation for Providers:
The most verbose, but also the most comprehensive one is a Provider recipe. The remaining four recipe types — Value, Factory, Service and Constant — are just syntactic sugar on top of a provider recipe.
That gives me the impression that all services are also providers. But I'm currently dealing with a problem using the $window service in my app's configuration block, and came across this bit of documentation:
A module is a collection of configuration and run blocks which get applied to the application during the bootstrap process. In its simplest form the module consist of a collection of two kinds of blocks:
- Configuration blocks - get executed during the provider registrations and configuration phase. Only providers and constants can be injected into configuration blocks. This is to prevent accidental instantiation of services before they have been fully configured.
Which implies there's a distinction between a provider and a service that's more fundamental than a service recipe simply being "syntactic sugar" over the provider recipe. What's the deal?