I have build a dialog service which dynamically create a DialogComponent with a child component.
I want my DialogComponent to be a generic class of <T>
since i wish to type for whatever component child i'm using. I'm currently create my DialogComponent using theses lines ->
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(DialogComponent);
const componentRef = componentFactory.create(new DialogInjector(this.injector, map));
The problem is that the resolveComponentFactory is actually returning a DialogComponent<{}>
instead of T
. I did try to cast but it's seem i can't because some methods is missing.
I'm wondering how i could achieve such thing !
Thanks.
EDIT
this.componentFactoryResolver.resolveComponentFactory<DialogComponent<T>>
did the tricks..