-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
RootInjector should append LazyModule's entryComponents [feature request] #17168
Comments
+1, I spent hours hunting this bug down only to discover it's impossible to fix without abandoning the modular paradigm. Not a good look! |
I'd seriously love to have this implemented. Even though it breaks the modular design, it would make life 10 timer easier. I leveraged the solution by passing the childInjector to the service and then ask for the ComponentFactoryResolver for the component I want to render. It's "hackish" but works... |
@renatoaraujoc +1 as said if child injector (from lazyload) is required by some usecases we can keep hope we'll receive news asap, i'm at 10% of my app and it is already big (more than 50 lazyload/module) |
Agree, the current behavior is unexpected and inconvenient especially working with modals in lazy loading modules. I have chosen to use https://github.com/ng-bootstrap/ng-bootstrap modals to avoid dealing with this. |
I was just triaging this issue, I don't have context or information. As it goes, having it on the backlog is the first step to resolve, but it might sit there longer. |
Perhaps a similar approach to what is done now in Angular6 with Related #23819 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
If you have a singleton service that uses a ComponentFactoryResolver provided by the App's RootInjector to dynamically create components and you wish to create an entryComponent declared in a lazy module, this will fail because the root injector does not know about it.
Expected behavior
This is actually the expect behavior considering that the root injector will not know about entryComponents known by the child injector.
What is the motivation / use case for changing the behavior?
The motivation is to leverage the complexity to create dynamic components though the modular design of Angular is correct.
Angular version: 2.4.9
Proposed solution: Even though this goes against the modular design adopted by Angular itself, I think that the complexity provided to create dynamic components could be softened by simply appending the LazyModule's entryComponents to the RootInjector's entryComponents and to avoid flooding the RootInjector, whenever you navigate out (which destroys the LazyModule), the previously injected entryComponents would be erased from the array.
Simply talking:
Hope I could suggest something good.
Thank you!
The text was updated successfully, but these errors were encountered: