Load modal component dynamically

I am trying to load a component dynamically into a modal box but I can’t seem to figure out how to do this correctly.

I managed to load the component dynamically by its name. I can then add it to the page:

    const factories = Array.from(this.componentFactoryResolver['_factories'].keys());
    const factoryClass = <Type<any>>factories.find((x: any) => x.name.toLowerCase() === "componentname");
    const componentFactory = this.componentFactoryResolver.resolveComponentFactory(factoryClass);
    let compRef = this.detailcontainer.createComponent(componentFactory);

But how can I add it to the component property when creating a modal dialog? compRef is of typeComponentRef<any> but component expects the type ComponentRef.

    return this.modalController.create({
      component: ???
    }).then((x) => x.present());

Thanks for helping!