Reputation: 3029
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.
Upvotes: 1
Views: 119
Reputation: 657068
var cmpRef = this.wrapperRef.createComponent(a, 0);
cmpRef.instance.someInput = someValue;
cmpRef.instance.someOutput.subscribe(val => this.value = val);
Upvotes: 1