I have a list of text entries followed by a button:
<li *ngFor="let match of matches; let i = index">
{{ match}} <button (click)="select(i)">Copy</button>
</li>
and I would like to copy the text to the clipboard when the user cliked the button.
public select(index:any){
document.execCommand("copy");
}
This does work, however, I somehow have to select the text of the corresponding text first. How can I do this in Angular2?