I work on Angular 4. My page has many checkbox and a share button. If any check box is selected and share is clicked a service is called and the download URL for that checkbox is returned. I have to copy this returned URL so that if user want he can paste it in notepad/browser. How to copy text in a variable inside javascript/typescript/Angular? Please guide.
<div *ngFor="let hero of heros">
<span>
<input type='checkbox' name='drama' />
</span>
<span>hero.name</span>
</div>
<button [class.disabled]='!inEditMode' (click)='selectedHero()'>Share</button>
selectedHero(){
var elements = document.getElementsByName("drama");
for (let i = 0; i < elements.length; i++) {
if (elements[i].type == "checkbox") {
if (elements[i].checked) {
//Service call is made here and the URL is stored in "this.docURL"
}
}
}
}
How to copy the value inside "this.docURL" ?