Closed
Description
Which @angular/* package(s) are the source of the bug?
core and cdk
Is this a regression?
Yes
Description
After upgrading to Angular 19, many of our "Modal" componants throw NullInjectorError errors.
We use ComponentPortals to dynamically create a component and display it as a modal/dialog we also pass in the injector of the "host" component to ensure the modal component has DI access to all the same services as the host.
However this issue is also reproduceable using the Dialog service from the cdk as illustrated in the attached github project.
Our project is very large and we have been slowly transitioning to standalone components, but this is a long process and the majority of the code still uses modules.
Please provide a link to a minimal reproduction of the bug
https://github.com/Lightw3ight/ng-19-di-bug
Please provide the exception or error you saw
module-based-thing.component.html:1 ERROR NullInjectorError: R3InjectorError(Environment Injector)[_MyTestService -> _MyTestService]:
NullInjectorError: No provider for _MyTestService!
at <instance_members_initializer> (dynamic-thing.component.ts:10:29)
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 19.1.8
Node: 22.14.0
Package Manager: npm 10.9.2
OS: win32 x64
Angular: 19.1.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1901.8
@angular-devkit/build-angular 19.1.8
@angular-devkit/core 19.1.8
@angular-devkit/schematics 19.1.8
@angular/cdk 19.1.5
@angular/cli 19.1.8
@schematics/angular 19.1.8
rxjs 7.8.2
typescript 5.7.3
zone.js 0.15.0
Anything else?
No response