{"type": "session", "harness": "opencode", "id": "angular-di", "name": "Angular Dependency Injection"} {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer."}} {"type": "message", "message": {"role": "user", "content": "How does Angular's dependency injection work?"}} {"type": "message", "message": {"role": "assistant", "content": "Angular DI uses a hierarchical injector system:\n\nNullInjector (ultimate parent)\n -> PlatformRef Injector (platform services)\n -> EnvironmentInjector (app/module scope, R3Injector)\n -> NodeInjector (element-level, LView/TView-based)\n\ninject(token) searches: NodeInjector -> EnvironmentInjector -> PlatformInjector -> NullInjector.\n\nProvider types:\n- Class: { provide: Token, useClass: Class }\n- Value: { provide: Token, useValue: val }\n- Factory: { provide: Token, useFactory: fn }\n- Existing: { provide: Token, useExisting: Other }\n\nResolution modifiers:\n- Self: only current injector\n- SkipSelf: start at parent\n- Optional: return null instead of throwing\n- Host: stop at host component boundary\n\nNodeInjector uses LView/TView for element-level DI, avoiding full injector tree traversal.\nChainedInjector combines EnvironmentInjector and NodeInjector for performance."}}