NullInjector is Angular’s terminal injector. It sits above the root injector and always throws when dependency lookup reaches it without finding a provider. section 3.1.3
The resulting message, “NullInjectorError: No provider for Something!”, means Angular searched the injector hierarchy, reached the root, and found no matching provider. section 3.1.3
NullInjector clarifies the final stage of Angular’s dependency lookup:
- Angular searches through its hierarchy of injectors, including element-specific and root-level injectors. section 3.1.3
- ElementInjector instances can provide different values for the same token, such as an ElementRef tied to a particular directive instance. section 3.1.3
- NullInjector provides no fallback value; reaching it indicates that the requested dependency remains unresolved. section 3.1.3
Figure 3.2 Diagram illustrating the hierarchy of injectors and dependencies
Use the injector hierarchy diagram to trace how dependency lookup proceeds from a component through element and root injectors to NullInjector. section 3.1.3
