Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Injector Trees
Search
Kapunahele Wong
July 02, 2019
29
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Injector Trees
Slides for my talk at the Techmaker Meetup in Reading, UK.
Kapunahele Wong
July 02, 2019
More Decks by Kapunahele Wong
See All by Kapunahele Wong
Contributing to the Angular Docs
kapunahelewong
1
91
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
Tell your own story through comics
letsgokoyo
1
1.1k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
The Cult of Friendly URLs
andyhume
79
7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Navigating Team Friction
lara
192
16k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
Scaling GitHub
holman
464
140k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
KATA
mclloyd
PRO
35
16k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
Designing Experiences People Love
moore
143
24k
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!!!