title: How to bind on click event on dynamically created button in Angular 6?
body: <p>I am trying to create a dynamic button with an onclick event. The showname() defined the on same Component.ts. But there is no response on clicking the button</p>
  
  <blockquote>
    <p>Component.ts</p>
  </blockquote>
  
  <pre><code>createtooltip() {
    this.tooltip = document.createElement('div');
    this.tooltip.style.cssText =
      'position:absolute; background:black; color:white; padding:4px;z-index:10000;' +
      'border-radius:2px; font-size:12px;box-shadow:3px 3px 3px rgba(0,0,0,.4);' +
      'opacity:0;transition:opacity 0.3s';
    this.tooltip.innerHTML = '&lt;button id="popup" (click)="showname()" &gt;Copy!&lt;/button&gt;';
    document.body.appendChild(this.tooltip);
  }
  
  showname() {
    console.log("Hi User");
  }
  </code></pre>
  
  <p>Could anyone help me to find the solution?</p>