Hi everyone.
Let me summarize the dependency injection techniques a little bit.
Actually, the dependency injection is a design pattern.
Okay.
Now.
When we mark the class will be injectable, and import it's inside the provider of the module.
What's actually happened under the hood, it will create the something called IOC container.
Inversion of control container or dependency injection container.
This will be the same.
Okay.
But I think I will go.
That will be the IOC container.
And when we mark the object will be @Injectable.
And import it inside the module providers.
It will create the IOC container and pass the object into here.
Test service
Okay.
And test repo
Okay.
And later, when the some controller wants to access into the test service, it will auto look up inside
the IOC container and take the test service.
Okay.
And pass it inside the parameter of the constructor.
You can see, it will pass it directly right here.
Into the controller.
And all of that are done by the.
NestJS framework.
Okay.
Hopefully this makes sense right.
Let me write a flow one more time.
Firstly
--
Firstly, the controller.
The controller is say: it has a dependency.
Okay.
The controller.
The controller I have a dependency.
And for that reason, it will look up into a IOC container.
And.
Say.
In this case will be test service object creation.
Okay.
Test service object, not test service class.
Okay.
This is clearly the object creation.
Okay.
It will take test service object and pass it inside the controller.
Okay.
That's the how.
Dependency injection work.
Hope you understand this video.
I will see you in the next one.