In this video, we will see how the Dependency Injection (#DI) works in #angular. We will also see the Inversion Of Control (#IoC) principle, and the Dependency Inversion Principle (#DIP).

The Dependency Injection is a design pattern under the umbrella of the Inversion Of Control principle.

In the Angular Providers, when we use #useClass, Angular will try to create a new class instance.
When we use #useExisting, we tell Angular to use an existing class instance.

In this example, the correct approach is to use #useExisting since the loggers are singleton and we don’t need to create a new instance.

Code: https://github.com/profanis/codeShotsWithProfanis/tree/15/dependencyInjection

#angular #angular tutorial #what is angular

Dependency Injection In Angular
1.10 GEEK