-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix(modal): modal does not properly work in a lazy loaded module #2356
Comments
Is there a workaround? I have exactly the same issue Edit |
Running into the same issue. Could you share an example please? |
@psined1 Just import |
yep, did that, works fine |
Also having the same issue. The workaround pointed by @dzonatan fixes it, but I don't know what are the implications of using forRoot in a child module. |
Having same issue, is there an update? |
I wouldn't reimport I think the easiest solution would be (while still somewhat kludgy), for the lazy loaded module to provide its own |
advances? |
Any updates on this? |
Nov 2018, still broken? |
#3361 aims to fix it, but according to @valorkin it is still broken. Sadly, the modal roadmap issue #3258 does not show progress for about a year, too 😢 Edit: You can use |
Any updates on this? |
I needed to perform an action every time I opened a modal in a lazy module to be able to do this. I create a shared module and import the modal module and in the constructor add a listener to the event emiter that the BModalService has. In this way I was not forced to be repeating this in all the modules where I wanted to do this. I hope you can help them this. |
Same problem, after almost two years ;( As a side note, I've tried to apply workaround that @thetric proposed - yes, it works but only until you need Disappointed... |
Any update on the issue? |
I believe this is an Angular issue here. But wow, this issue still not closed. |
This is not entirely an angular issue. The way how ng works is not compatible to your guys implementation. The lazy load module encapsulation will never allow provide lazy load factories on global FactoryResolver. The way ng team and obter libs fixed this issue is working w/ two services. One provided in Module Scope, dedicated to resolve component reference. And a second service provided in root scope to handle multiple modal instances. In short, the local service will resolve the component reference w/ local factory resolver, and then inject a global service to deal w/ multiple instances of resolved components/modals. |
¿Any updates on this? I'm getting multiple modalService instances because of the "ModalModule.forRoot()" workaround, and by doing this I can't use "setDismissReason" and the "onHide" event properly for all the modals. Thanks for the great library. |
Bringing this issue up again. |
And again |
@jeserkin No, it's actually not an issue with Angular 9 :) I got rid of it after the upgrade. |
So to conclude. Update to Angular 9 and |
But it still generates multiple instances of modalService(one for each lazy loaded module) which is not correct. |
Doesn't tooltip and popover do the same? They also require TooltipModule.forRoot(), PopoverModule.forRoot() as far as I know. |
To have working modal in a lazy-loaded module you have to import modal module with
forRoot()
in that lazy module which is not correct asBsModalService
will get a new instance and will not know anything about other modals of other modules (e.g. nesting won't properly work). If you skip theforRoot()
you will get:That's happening because ComponentLoaderFactory is provided only in root module which does not know anything about lazy-loaded injector and factories.
Proper fix would be to have some kind of overlay service that is provided with every ModalModule import.
Reproduction - https://stackblitz.com/edit/ngx-bootstrap-playground-mtwpzg
The text was updated successfully, but these errors were encountered: