Chris Pawlukiewicz
Aug 23, 2017 · 1 min read

Create a DynamicFormComponent component that uses ViewContainerRef and ComponentFactoryResolver to dynamically render a component that it’s passed as Input. Add an output isValid to it.

Use the same methods above in the rendered component to emit the valid state of the form to the parent by subscribing to the isValid and passing it to the dynamic components isValid output like so:

const comp = this._componentFactoryResolver.resolveComponentFactory(this.component);
const instance = this.container.viewContainerRef.createComponent(comp).instance;
instance['isValid'].subscribe(e => this.isValid.emit(e));

)

    Chris Pawlukiewicz

    Written by

    Novelist, technology freak, software developer, entreprenuer. Founder of kingdomworks — https://kingdomworks.io

    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