The most apps need some sort of Runtime configuration information, which it needs to load at startup. For example, if your app requires data, then it needs to know the base location of your REST endpoints. This endpoints are not fixed and may have different values for development, testing & production.
Angular Dependency Injection
The APP_INITIALIZER is an instance of InjectionToken. It is a built in Injection token provided by Angular. The Angular will execute the function provided by this token when the application loads. If the function returns the promise, then the angular will wait until the promise is resolved. This will make it ideal place to perform some initialization logic before the application is initialized.
In this tutorial, we will look at Angular 2 Injector, one of the parts of the Angular 2 Dependency Injection Framework. The Angular 2 creates a tree of injector & Providers which resembles the Component Tree. This is called hierarchical pattern.
Angular 2+ Providers allow us to configure set of dependencies. It tells Angular injector how to create the instance of dependency. We register our all our dependencies with the Angular Providers. we will learn all these in this tutorial
In this tutorial, what is Angular Dependency Injection is and how to inject dependency into a Component by using an example. The Angular is designed from the ground up to support and leverage dependency injection