Learn How to Use the Inject Method in Angular 14

preview_player
Показать описание
In Angular 14 we can use the inject() method which is a new way to apply Dependency Injection in our Angular applications.
We can use this method during the class creation or initialization and can be used as a class field, in the class constructor body, and in a factory method.

Chapters:
0:00 Intro
0:25 inject method in the constructor body
4:44 inject method as a class field
10:07 inject method in a factory function
14:10 Summary
14:29 Thank you

******************************************************
Let's connect
******************************************************

#angular #learnAngular #angularTutorial #dependencyinjection #singlepageapplication #web #webdevelopment #webdeveloper #angulardevelopment #frontenddeveloper
Рекомендации по теме
Комментарии
Автор

WOW!
great example for inject. first time I subscribe after one video watch

qgijdwj
Автор

Good teacher! Easy to understand you deserve more subs!

owenjaspervargas
Автор

Thank you master Profanis!)
The most valuable one thing to learn from this is that inheritance begins to seem a little more useful now)
Btw, inject() in a context of factory provider could be used for a pretty long time, I think when ivy got into a play or so

arthurfedotiew
Автор

that was very powerful, thanks so much

hadirahmani
Автор

How did you make the param name to show on vscode? Like in the logger token, it shows _desc as param name. Really helpful video. Thanks man

antt
Автор

Hello . I would like to add that we can use the Inject method in any other hook or lifecycle, except from constructor utilizing the power of closures, as we are able to store the injected token inside the closure scope and still use values in the returned function. 😁😁😁|

exort const dispatchSearch = (): ((search: string) => void) => {
const store = inject(Store);
return (search) => store.dispatch(new SetSearch(search))
}

XHANITRUNGUMANOS
Автор

Hello.. thanks for your video...! why i am facing this issue? " NG0203: inject() must be called from an injection context"

rafaelpanayiotou
Автор

Thak you profanis .
Have understood it as way to reduce dependecies in the constructor, so they can be declared as global functions or variables, is that a correct take home

fahadgaliwango
Автор

Pluck is being deprecated. You should update to use map operator

seanpheneger
Автор

Thank you, very interesting, I think I need to repeat a lot of stuff about Class, to properly understand what is going on here ). Also what is a difference between take(1) and first()?

OlehBiblyi
Автор

Well, that's a mess. inject() anywhere and everywhere. Peer Reviews, debugging and defect fixing are going to be more fun.

zshn