CdkPortalOutlet should resolve componentFactories through the portal's ComponentFactoryResolver
See original GitHub issueBug, feature request, or proposal:
At the moment, CdkPortal
tries to resolve ComponentFactories
via its own CFR which it got from its own Injector
instance:
const componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
It may happen that you’d like to attach a ComponentPortal
with a lazily loaded entryComponent
that’s not resolvable through the PortalHost's
CFR. It should then try to get a CFR instance from the Portal to resolve the ComponentFactory
if it can’t resolve it through its own:
const componentFactory = portal.injector.get(ComponentFactoryResolver).resolveComponentFactory(portal.component);
I’m not sure if this has any negative side effects.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:14 (7 by maintainers)
Top Results From Across the Web
How to use CdkPortalOutlet with component in different module
Currently, I'm using Module Factory and component factory. Is it possible to use Angular portals and load the component's module?
Read more >Inject dynamic content in Angular components with portals
Learn how to dynamically render content in your Angular components using Angular CDK portals in this in-depth tutorial.
Read more >Angular CDK Portals - Medium
The @angular/cdk contains a concept called portals. In this post I'll attempt to explain the concepts of a Portal, and when they should...
Read more >Here is what you need to know about dynamic components in ...
We start with the comparison of dynamic components functionality in Angular and ... It's a job of a compiler to resolve all the...
Read more >UNPKG - @angular/cdk
@angular/cdk/bundles/cdk-portal.umd.min.js.map ... Injector | null;\n\n /**\n * Alternate `ComponentFactoryResolver` to use when resolving the associated ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s a good point; you’d want the resolver to be associated with the
ComponentPortal
in that case. That makes more sense anyway, sinceTemplatePortal
doesn’t use the resolver at all. The simplest thing would probably be adding aComponentFactoryResolver
as a 4th argument to the constructor forComponentPortal
. I would shy away from trying to get it from the giveninjector
because someone might want to use an injector from a totally different part of the application tree.@crisbeto you closed the linked PR stating that this wouldn’t be necessary in Angular 6+. Could you elaborate on how resolving factories has changed?
Thank you for your work!