Angular · Senior · Question 16 of 75
In which order does Angular resolve inject(Token) in a component?
- ✓Correct answer: Element injectors up the component tree, then environment injectors (route → root → platform), then
NullInjector - 2Root injector first, then the component's own providers
- 3Only the injector of the current module
Explanation
The nearest provider wins, which is how a component can override a root service for its subtree. If nothing is found, NullInjector throws unless the injection is optional.