Angular Dependency Injection In-Depth
summary
Covers how Angular resolves tokens through two injector types — component/element injectors and the R3 module injector — and why a null injector error appears when nothing is provided. Demonstrates a CounterService example to show lazy instantiation, multiple instances when provided at component nodes, and shared singletons when using providedIn: "root" or providedIn: "platform". Explains provider forms (useClass, useValue, useFactory, useExisting), decorators like skipSelf and optional, and creating typed InjectionToken constants.
AI-written summary · about
chapters (11)
- 0:00Introduction to DI
- 2:30Injector hierarchy explained
- 8:12Registering dependencies
- 17:49Lazy instantiation of services
- 22:13Node injector vs module injector
- 30:07Controlling instance scope
- 38:43Root level injector
- 40:10Optional decorator usage
- 44:30Multiple module bootstrapping
- 50:41Injection tokens for constants
- 57:07Summary and resources
related talks
46mAngular Dependency Injection – Understanding hierarchical injectors
57mAngular Dependency Injection, In Depth
29mDI Deep Dive
39mSimplifying DI and Services in Angular
38mDependency Injection for Future Generations
17mDissecting Dependency Injection: Angular and NestJS
23mDependency Injection in Nest and Angular: Intersection & Mismatch
11mMastering Angular’s Dependency Injection
