
Learning Angular
By :

DI is an application design pattern we also come across in other languages, such as C# and Java. As our applications grow and evolve, each code entity will internally require instances of other objects, better known as dependencies. Passing such dependencies to the consumer code entity is known as an injection, and it also entails the participation of another code entity called the injector. The injector is responsible for instantiating and bootstrapping the required dependencies to be ready for use when injected into a consumer. The consumer knows nothing about how to instantiate its dependencies and is only aware of the interface they implement to use them.
Angular includes a top-notch DI mechanism to expose required dependencies to any Angular artifact of an Angular application. Before delving deeper into this subject, let’s look at the problem that DI in Angular is trying to address.
In Chapter 3, Structuring User Interfaces with Components, we learned...