EP 10.6 - Angular / Dependency Injection & Providers /Providers and viewProviders

preview_player
Показать описание


We can configure the DI framework in Angular in three main ways.

We can configure a provider on the NgModule, on a component or directives providers property and on a components viewProviders property.

Deciding where to configure your provider and understanding the difference is the key to understanding how to architect an Angular application.

If we want an instance of a dependency to be shared globally and share state across the application we configure it on the NgModule.

If we want a separate instance of a dependency to be shared across each instance of a component and it’s children we configure it on the components providers property.

If we want a separate instance of a dependency to be shared across each instance of a component and only it’s view children we configure it on the components viewProviders property.
Рекомендации по теме
Комментарии
Автор

The bestest (if there is any word beyond best) video series on angular that I have ever gone through... thanks a lot Sir !!!!

sohininandi
Автор

Finally found a video which is not only introduced how to use DI but also showed how it works

Gaobyobyo
Автор

Great Tutorial, After watching your tutorial only I understand DI, You are a great teacher, Thank God I found your channel.... Thank you very much...

Josephrajp
Автор

I wish some day this teacher would share his method of self learning and how he decodes the essence of the concepts, I mean his scientific approach on investigating the real picture and meaning behind framework. So injection is a method of declaring your own types of variables and the way of injection is the scope/context of visibility of those variables
And yes, of course - a huge thanks on providing this course, invaluable, a real thing

evraya
Автор

This is a masterpiece on Providers. Simple and straightforward

DeivitMV
Автор

this made the concept of view providers so much clear ! Thankyou !

rhea
Автор

Thanks so much - watched it half away across the globe. Well explained complete with animations.

rembautimes
Автор

The only place where I totally understood the concept of Providers and in turn Injectors and also differentiated the DI in Angular from .Net Core since I'd relate to .Net Core to understand it. Awesome explanation, awesome example and really awesome knowledge all round.

expertreviews
Автор

Best explanation ever, Thank you so much!

danielalejandrocoronelberr
Автор

wooow
It was really impressive
Thank you for sharing this fantastic video about an important DI topic in angular.

erfanfarhadi
Автор

Great session! On stop to learn DI. Many thanks.

chaitanyanarlawar
Автор

Amazing way to explain it thanks for removing the ambiguity on top of this subject.

reduser
Автор

Thank you very much! I feel like I finally understand providers

kimdavidj
Автор

Thanks for your video, I finally understood how does it work

shanglia
Автор

What you mentioned in 12:52 is correct provided the parent component doesn’t have a providers property for the same service.
In other words, if I have both viewProviders: [SimpleService], providers:[SimpleService] set in parent component then the projected ng-content seem to work like before. Although, I couldn’t find an explanation to this behaviour in angular.io.

satrajitacharyya
Автор

Great explanation, many thanks for your work, Asim. Will definitely be buying your courses on Udemy.

michalstan
Автор

Great Job, Thank you for you tutorial

kevinmikeherreravega
Автор

great video thanks! how'd you make the diagrams? very nice with the arrows animating in, is it a slide show?

RobertKing
Автор

single word to say that awesome.. <3

devsoul
Автор

That was Great thank you !
the only thing that I needed to know is that providers inject the same Instance (singleton)

harryjohn