function provider(name, provider_) {
assertNotHasOwnProperty(name, 'service');
if (isFunction(provider_) || isArray(provider_)) {
provider_ = providerInjector.instantiate(provider_);
}
if (!provider_.$get) {
throw $injectorMinErr('pget', "Provider '{0}' must define $get factory method.", name);
}
return providerCache[name + providerSuffix] = provider_;
}
https://github.com/angular/angular.js/blob/master/src/auto/injector.js#L655-680
I was actually looking at the provider function of injector.js, it seems that all the services[constant, value, factory, service and provider itself] is a mere wrapper of the provider.
Can anyone help me in understanding these questions:
- Why are all these a
wrapperofprovider? Let's take i have afactory/servicenamed "Shane", why would i pass it to aproviderto create the "Shane" Object? - Why is there a
provider/servicethen?