I want to use dynamic button in html and on click of it I want to call a function in angular. I am using angular 7. Now i found solution like put button tag in angular statically . But I don't want to use that, because I will have multiple buttons, inputs , date picker , time picker dynamically. So please help me on this. I have been research on this from last 2 days but not getting a perfect solution. I have been use innerHtml as well . But its not working. I have used sanitizer , it show button now in html but its click function is not working. its not calling my function.
Statically its working but on dynamic its not working. Please check my code below.
<br><h4>Dynamic</h4><br>
<div contenteditable="true [innerHtml]="dyanmicHtmlString"></div><br>
<h4>Static</h4><br>
<button (click)="somefunction()">Static Button</button>
this.dyanmicHtmlString = '<button (click)="somefunction()">Dyanamic Button</button>