liveBook · Manning

Root injector

As explained in Modern Angular

A root injector is the globally scoped Angular injector created when an application starts.

A root injector is the globally scoped Angular injector created when an application starts. Services declared with providedIn: 'root' are registered there and can be injected throughout the application. section 3.1.3

Angular resolves dependencies through a hierarchy:

  • ElementInjectors belong to rendered DOM nodes and can use providers declared on components. section 3.1.3
  • Older NgModule applications used ModuleInjectors after ElementInjectors failed to resolve a dependency. section 3.1.3
  • Fully standalone applications omit ModuleInjectors and can register providers through routes or main.ts configuration before reaching the root scope. 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 searches for dependencies from component scope toward application-wide providers. section 3.1.3

How Modern Angular covers it

How deep it goes
Explains creation, provider registration, and hierarchical lookup, while deferring broader injector implementation details.
Examples
Uses providedIn: 'root', component providers, EmployeeService injection, repeated EmployeeListComponent instances, and standalone configuration.
What it assumes
Assumes familiarity with Angular components and constructor injection while establishing the injector's role in dependency injection.
What you can do after
Understand how Angular locates application-wide and component-scoped dependencies across standalone and NgModule-based applications.
How it connects
Connects dependency injection with providers, ElementInjector, ModuleInjector, NgModule, standalone components, routes, and main.ts configuration.

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.