I have a component where I am dynamically injecting another component. Please refer the code shown below:
getID() {
const componentRef = this.componentFactoryResolver
.resolveComponentFactory(CodesComponent).create(this.injector);
componentRef.instance.terms = this.terms;
this.appRef.attachView(componentRef.hostView);
const domElem = (componentRef.hostView as EmbeddedViewRef<any>)
.rootNodes[0] as HTMLElement;
$(domElem).insertAfter($(event.target).closest('tr'));
}
Also there is a function in my component:
sayHello() {
console.log('hi');
}
And my CodesComponent looks like below:
<p (click) = "sayHello()"></p>
Now question is how can I call sayHello() function from dynamically created component?
CodesComponent?<p (click) = "sayHello()"></p>this line of code I have in my dynamic component.