That little nomenclature blip in Angular providers

Providers are not something you use regularly. Reason-perhaps the fact that they are not as convenient as services /factories. What I meant was that with no syntactic sugar it just repels any new developer. If there are other ways you can have singletons why get into the hassles of have a provider at all ?

In the ascending order of their syntactic complexity but descending order of sophistication, any angular developer would agree to arrange the services like this ..

1. Service
2. Factory
3. Provider

A provider is the last resort that a angular developer takes and logically so. Service / factory does the same job. Why in the world then would you want a Provider ?

Simple app.config( ) takes in only providers and no other singleton services.

But then it does not work so easily, does it ?
One of the gists ( illustrates the distinction of using each in the required context and innocently misses out that when you are using a provider you need to watch out for the ‘pitfall’. I must admit though the gist does a real good job of explaining the differences, and no where on the web did I find anything more convincing. Not even the Misko Hevery answer here !! :!msg/angular/56sdORWEoqg/HuZsOsMvKv4J

I was not any different than you. I was looking for resources that could explain me the difference of all these services and which one is best suited for what kind of scenarios. From a distance we C# guys always dreaded the JS world and this juncture when we have taken the plunge, is when we start to realize how frosty the water really is.Nevertheless, once you catch the differences of all these 3 and eventually come to the conclusion that they are almost all the same and then the choice of one of them then is purely a convenience.

You then struggle to get the provider injected in the config delegate.

See the below code .. nothing working ~!

provider not working
provider not working

Most of the top Google search result pages on this issues rant about how the config runs before all the services are registered and the reason why you get the ‘unknown provider’ error. There is enough evidence on as well which can make you believe that as well..

But what worked for me was again a simple tweak in the name 🙂

provider working
provider working

Providers work when you drop the ‘Provider’ name appendix from the registration ! AHA!, now that things are working fine againt lets get back to coding on our superhero JS framework.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

Up ↑

%d bloggers like this: