Netanel Basal
Aug 27, 2017 · 1 min read

I’d probably do something like that:

// Else it’s a component
const factory = this.resolver.resolveComponentFactory(this.content);
const componentRef = factory.create(this.injector);
// Add this as new Input
if(this.inputs) {
Object.keys(this.inputs).forEach(input => {
componentRef.instance[input] = this.inputs[input];
});

componentRef.changeDetectorRef.detectChanges();
return [ [ componentRef.location.nativeElement ] ];

But I would avoid it and just pass a smart component that renders dumb components and handle their state with a Service/Store.

)

    Netanel Basal

    Written by

    I'm a Frontend Architect at Datorama, blogger, open source maintainer, creator of Akita and Spectator, Husband, and Father.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade