1

I use this method to Dynamically add a Component in RC5:

@ViewChild('wrapper', {read: ViewContainerRef}) wrapperRef: ViewContainerRef;

constructor(
    private _comp: Compiler
) {}

ngOnInit() {
    this._comp.compileComponentAsync(this.childComp).then(a => {
        this.wrapperRef.createComponent(a, 0);
    });
}

But i'm not sure how to add input values to the created component.

1 Answer 1

1
var cmpRef = this.wrapperRef.createComponent(a, 0);
cmpRef.instance.someInput = someValue;
cmpRef.instance.someOutput.subscribe(val => this.value = val);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the quick answer :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.