Simplifying DI and Services in Angular
summary
Live demo uses Angular 9, a CLI-generated log service with a static counter and an InjectionToken plus useValue configs to show exactly how many instances Angular creates and when code is bundled. Default providedIn: 'root' services are singleton and tree‑shakable; putting a service in the providers array forces inclusion and can create extra instances. Using providedIn: 'any' yields separate instances per lazy module so different endpoint/token values work; the demo builds, lazy loads modules, and shows three instances created when expected.
AI-written summary · about
chapters (10)
- 0:00Introduction to DI
- 1:03DI core concepts
- 3:56Creating a service
- 5:57Singleton vs tree-shakable
- 13:03Provider configuration
- 14:43Services in lazy loading
- 20:16Passing dynamic data
- 25:29Managing module data
- 29:41Service isolation strategies
- 35:16The power of 'any'
related talks
01h 00mAngular Dependency Injection In-Depth
46mAngular Dependency Injection – Understanding hierarchical injectors
57mAngular Dependency Injection, In Depth
39mDeep DI-ving: how Angular's DI system defeated a monolith
30mClimbing up injector trees
29mDI Deep Dive
20mEngineering Scalable Angular Components
28mProcessor Pattern with Angular Dependency Injection
