Angular2–provide: Provider[]
A quick write-up to understand Angular2 providers.
Published in
1 min readApr 23, 2017
Angular2 ships with a dependency injection system that utilizes providers to create and deliver services.
There are basically four kinds of providers: ClassProvider, FactoryProvider, TypeProvider, and ValueProvider. They are accessible using a common, so-called ‘union type’ Provider.
Here is a code sample that illustrates how to use the different kinds of providers. All provider expressions are achieving equivalent results.
Let’s jump in!
Note: the presented code is not intended to be used in production, but rather for learning purposes.