Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Injector Trees
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kapunahele Wong
July 02, 2019
0
23
Injector Trees
Slides for my talk at the Techmaker Meetup in Reading, UK.
Kapunahele Wong
July 02, 2019
Tweet
Share
More Decks by Kapunahele Wong
See All by Kapunahele Wong
Contributing to the Angular Docs
kapunahelewong
1
73
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
760
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
170
Mobile First: as difficult as doing things right
swwweet
225
10k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.6k
Mind Mapping
helmedeiros
PRO
1
91
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
160
Amusing Abliteration
ianozsvald
0
110
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.1k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
110
Transcript
INJECTOR TREES Kapunahele Wong @kapunahele
angular.io/docs
In the works
None
And on its way…
LOTS. TUTORING @kapunahele @mhevery
IN-DEPTH WITH URI SHAKED & ME ANGULAR CONNECT @UriShaked Photo
credit: Ashnita Bali! @kapunahele
https://github.com/angular/angular/issues
Services @kapunahele
According to the docs: @kapunahele In Angular, a service is
an instance of a class that can be made available to any part of your application using Angular's dependency injection system. From: https://angular.io/start/data
@kapunahele Angular's dependency injection system Stuff in Trees a service
is an instance of a class that can be made available => => =>
Injector trees @kapunahele
ONLY TWO TYPES OF INJECTORS* ▸ModuleInjector ▸ElementInjector @kapunahele
ModuleInjector @kapunahele
MODULEINJECTOR ▸@NgModule.providers ▸@Injectable.providedIn @kapunahele
MODULEINJECTOR ▸@NgModule.providers @kapunahele
MODULEINJECTOR ▸@Injectable.providedIn @kapunahele
MODULEINJECTOR @kapunahele
MODULEINJECTOR @kapunahele
MODULEINJECTOR @kapunahele
ElementInjector @kapunahele
ELEMENTINJECTOR ▸@Component.providers ▸@Component.viewProviders @kapunahele
ELEMENTINJECTOR ▸@Component.providers @kapunahele
ELEMENTINJECTOR ▸@Component.viewProviders @kapunahele
ELEMENTINJECTOR @kapunahele
One is not the parent of the other @kapunahele ModuleInjector
& ElementInjector
ModuleInjector @kapunahele ElementInjector Source: https://svs.gsfc.nasa.gov/11650
ModuleInjector @kapunahele ElementInjector Source: https://svs.gsfc.nasa.gov/11650
ModuleInjector @kapunahele ElementInjector Source: https://svs.gsfc.nasa.gov/11650 1 2
Another analogy @kapunahele
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
ModuleInjector @kapunahele ElementInjector 1 2
Sample apps @kapunahele
MODULEINJECTOR @kapunahele
Our given values: @kapunahele FlowerService: AnimalService:
MODULEINJECTOR @kapunahele
MODULEINJECTOR @kapunahele
ELEMENTINJECTOR @kapunahele
Our given values: @kapunahele FlowerService: AnimalService:
ELEMENTINJECTOR @kapunahele
ELEMENTINJECTOR @kapunahele
So, why two? @Component.providers @Component.viewProviders @kapunahele
@kapunahele
@kapunahele Angular’s logical view representation
@kapunahele <#VIEW> represents an instance of a template and each
component has its own <#VIEW>
@kapunahele Inject the FlowerService: Basic example (ModuleInjector) Add binding in
MyAppComponent template: Renders:
@kapunahele In the logical tree: Basic example (ModuleInjector)
@kapunahele @Component.providers array
@kapunahele @Component.providers
@kapunahele @Component.viewProviders array
@kapunahele @Component.viewProviders
@kapunahele @Component.providers
Visibility decorators @kapunahele
@Host() @kapunahele @SkipSelf() @Self() @Optional()
@Optional() @kapunahele
@Self() @kapunahele
@SkipSelf() @kapunahele
@Host() @kapunahele
@kapunahele The visibility decorators can make different things visible depending
on whether you’ve used @Component.providers or @Component .viewProviders. (Think <#VIEW>)
@kapunahele 1. Two injector trees 2. ElementInjector first, ModuleInjector second
3. Use visibility decorators to customize where the injector starts and stops looking Recap:
https://github.com/kapunahelewong/ element-injector-tree @kapunahele https://github.com/kapunahelewong/ module-injector-tree ElementInjector Demo ModuleInjector Demo Thank
you!!!