How Dependency Injection In

Опубликовано: 22 Март 2025
на канале: Code Shots With Profanis
1,880
79

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 Angular Providers, when we use the #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.

Chapters:
0:00 Intro
0:22 manually create class instances
5:14 dependency inversion principle
11:15 angular dependency injection (IoC)
16:55 abstractions vs concrete implementations
22:20 summary

Code: https://github.com/profanis/codeShots...

******************************************************
Let's connect
******************************************************
Twitter:   / prodromouf  
LinkedIn:   / prodromouf  

#angular #angulartutorial #learnangular