liveBook · Manning

Module injector

As explained in Modern Angular

A module injector is an Angular injector associated with NgModule-level dependency-injection configuration.

A module injector is an Angular injector associated with NgModule-level dependency-injection configuration. In the hierarchical lookup process, it is consulted when an ElementInjector cannot find a dependency in its registry. section 3.1.3

ModuleInjectors belong primarily to the pre-standalone Angular model. Standalone applications do not use them unless standalone components import NgModules; fully standalone applications instead rely on ElementInjectors and providers registered on routes or main.ts configuration. section 3.1.3

Resolving EmployeeService

When EmployeeListComponent requests EmployeeService, Angular checks the component's ElementInjector and continues hierarchically until it finds a provider. Rendering five component instances with *ngFor creates five ElementInjectors and repeats the lookup process for each instance. section 3.1.3

Figure 3.2 Diagram illustrating the hierarchy of injectors and dependencies
figure

Use the injector-hierarchy diagram to trace how Angular moves between ElementInjector and ModuleInjector levels while resolving dependencies. section 3.1.3

How Modern Angular covers it

How deep it goes
Explains hierarchical resolution through ElementInjector and ModuleInjector levels, then contrasts the fully standalone path.
Examples
Uses EmployeeListComponent, EmployeeService, and repeated component instances rendered with *ngFor.
What it assumes
Assumes familiarity with constructor injection, Angular components, providers, and the distinction between standalone and NgModule applications.
What you can do after
Evaluate how Angular resolves a service across component, module, route, and application-level providers.
How it connects
Connects NgModule providers with ElementInjector, root injector, standalone components, routes, and dependency injection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern Angular. The section links point to the parts of the book it draws on.