Angular & Signals (283 Qs)•Part 9: NgModules, Providers, NgZone & Injector Hierarchies (213 - 255)
What are the types of injector hierarchies?
There are two types of injector hierarchies in Angular
- ModuleInjector hierarchy: It configure on a module level using an @NgModule() or @Injectable() annotation.
- ElementInjector hierarchy: It created implicitly at each DOM element. Also it is empty by default unless you configure it in the providers property on @Directive() or @Component().
Practical Code Example
text
// Injector Hierarchies:
// 1. EnvironmentInjector Hierarchy (Root, Platform, Null)
// 2. ElementInjector Hierarchy (Component DOM tree)