📚 Read the book 👉 [ Ссылка ]
🔥 Level up your JavaScript 👉 [ Ссылка ]
🌿 If you find my videos useful please consider planting a tree for me 👉 [ Ссылка ]
🎥 Watch the full playlist 👉 [ Ссылка ]
The best place to view the code associated with this course is in the online book ([ Ссылка ]) via the book if a lecture has code associated with it, it then also has a link to a stackblitz instance so you can run and edit the code sample online.
There is one top-level injector created for each NgModule and then for each component in our app, from the root component down, there is a tree of injectors created which map to the component tree.
We configure these injectors with providers by adding the configuration to either the providers property on the NgModule, Component and Directive decorators or to the viewProviders property on the Component decorator.
We use the @Inject parameter decorator to instruct Angular we want to resolve a token and inject a dependency into a constructor.
We use the @Injectable class decorators to automatically resolve and inject all the parameters of class constructor.
This only works if each parameter has a TypeScript type associated with it, which the DI framework uses as the token.
We don’t need to use the @Injectable class decorator on classes which are already decorated with one of the other Angular decorators, such as @Component.
Now we know where we can configure providers in the DI framework in Angular.
In the next lecture, we will cover the differences between configuring providers on NgModule, Component.providers and Component.viewProviders.
Ещё видео!