I'm developing Angular 8 app and I want to insert HTML with angular bindings into my page.
So, my html code is:
<button (click)="insertHtml()">Insert</button>
<div id="text"></div>
My angular code is:
insertHtml() {
document.getElementById("text").innerHTML = '<span (click)="handleClick(' + this.item.id + ')" [hidden]="' + this.item.hidden + '">'
}
Html looks fine, but it doesn't show right css class and click handler.
Can I insert html with angular bindings dynamically? And if yes, what am I doing wrong?