title: How to create button dynamically with click event in angular 2+
body: <p>I want to create a button dynamically.I used innerHtml to do this.
  I can create button.But it's click event not working.
  Please tell me how to solve this?</p>
  
  <p>Here is my html code</p>
  
  <pre><code>&lt;div  [innerHTML]="answerPanelContent"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Here is my typescript code</p>
  
  <pre><code> answerPanelContent: any;
  
     constructor(private sanitizer: DomSanitizer){
  
     }
  ngOnInit() {
   this.answerPanelContent =  this.sanitizer.bypassSecurityTrustHtml(`&lt;button type="button" class="btn                                                    btn-primary float-left"
                                             (click)="removeAnswer()" title="Remove Answer"
                                             aria-label="Close"&gt;
                                            Remove&lt;/button&gt;`);
  
    }
      removeAnswer(){
        alert('clicked');
      }
  </code></pre>
  
  <p>Here is the stackblitz url: <a href="https://stackblitz.com/edit/angular-nka4w9" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-nka4w9</a></p>