-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: modal components don't have the correct injector #4447
Comments
I have the same problem. Does somebody know of a hotfix for this problem? |
We have the same problem and would appreciate a fix |
This really needs more attention. v.14.0.0 is currently completely broken for anyone using lazy loaded modules. |
Indeed, I think I've screwed up two things:
ng-bootstrap/src/modal/modal-stack.ts Lines 234 to 241 in 7f2146d
I think
ng-bootstrap/src/modal/modal.module.ts Lines 8 to 9 in 7f2146d
It should provide I'll open a PR ASAP |
If NgbModal needs to be provided by NgbModalModule for this bug to be fixed, does it mean that standalone components should have it in their |
I have the same problem here too. |
Provides `NgbModal` at the `NgbModalModule` level as well as at the 'root' level. Provides environment injector based on the `contentInjector` and not the `appRef.injector` when using component as modal content. Fixes ng-bootstrap#4447
@jnizet I've opened the PR |
Provides `NgbModal` at the `NgbModalModule` level as well as at the 'root' level. Provides environment injector based on the `contentInjector` and not the `appRef.injector` when using component as modal content. Fixes #4447
Thanks for the fix and for the release @maxokorokov. Works fine here. |
Bug description:
Since version 14, a component used as the modal content doesn't have the correct injector anymore.
If a lazy loaded module defines a provider for a service and a component from that module is used as a modal content and tries to get the service via DI, a
NullInjectorError
is thrown when opening the modal.Link to minimally-working StackBlitz that reproduces the issue:
https://stackblitz.com/github/jnizet/modal-repro/tree/ngb14
This repro is also available on github: https://github.com/jnizet/modal-repro
The
main
branch shows the code working with ng-bootstrap 13, and thengb14
branch shows the same code not working with ng-bootstrap 14.Versions of Angular, ng-bootstrap and Bootstrap:
Angular: 15.0.4
ng-bootstrap: 14.0.0
Bootstrap: 5.2.3
The text was updated successfully, but these errors were encountered: