title: Angular 4 - Copy text to clipboard
body: <p>I have a clickable icon on the page. On click on this icon, I would like to construct some text and copy that in the clipboard</p>
  
  <pre><code>&lt;td&gt;&lt;img src='./assets/Copy.gif' (click)="copyToClipboard()"  /&gt;&lt;/td&gt; 
  </code></pre>
  
  <p>and in the Component</p>
  
  <pre><code>  copyToClipboard() {
       this.textToCopy = this.text1 + this.text2 + this.text3;  
       this.toastr.info('Copied to Clipboard');
    }
  </code></pre>
  
  <p>I have looked at <a href="https://www.npmjs.com/package/ngx-clipboard" rel="noreferrer">https://www.npmjs.com/package/ngx-clipboard</a>. However, this package requires to refer to an input element and copy the text from that input element. In my use case, the text needs to be dynamically created and then added to clipboard.</p>
  
  <p>Can I use ngx-clipboard to copy to clipboard or is there be another package that would enable me to achieve this?   </p>