Add Events and Variable to Dynamically created Component Angular 4

Viewed 4253

I've a dynamically created component in my Angular app as follows:

const factory = this.resolver.resolveComponentFactory<IMessage>(MessageComponent);
this.component = this.container.createComponent(factory);
this.component.instance.body = message;

It is equivalent to adding <message [body]="message"></message> in component's HTML.

Let's assume that, I want to achieve something like this in my dynamic component code:

<message [body]="message" #form="my-form" (change)="myFunction()"></message>

How do I bind these additional variable and change events inside by component's ts file?

1 Answers
Related