- One of them is how Angular treats the relationship between host and child injectors, and the other one is how the visibility of dependencies are handled.
- We have three nested components that all do their own thing (because that’s what components do in Angular):
As we learned in our article on dependency injection in Angular, each component in Angular creates its own injector.
- The injector tree allows us to define injector providers for a specific component and its children.
- To make our code work as expected, all we have to do is to make the provider of explicitly available only for its view:
Now, whenever a component of ’s view asks for something of type , it’ll get an instance of as expected.
- Other child components from the outside world that ask for the same type however, won’t see this provider and will continue with the lookup in the injector tree.
Who do you think would benefit most from this? Host and Visibility in Angular 2's Dependency Injection > https://t.co/EqkwpAmaDu
— AngularJS News (@AngularJS_News) July 30, 2017
Tweets by PascalPrecht
Tweets by timche_
Tweets by tim_hartmann_