0

I'm doing a sample angular app and I have an html file and a typescript file. I made a function in the typescript file to handle the click event to where it copies a specific predefined text and in the html file I just had the function as the onclick event. Is it because I'm using document? The name of the file is blank-blank.component.html and blank-blank.component.ts I have seen other similar questions but it doesn't work for me. Mine is an tag and the other solutions don't work on this.

  myFunction() {
    let copyText = document.getElementById('HI WASSUP') as HTMLInputElement;
    copyText.select();
    document.execCommand('copy');
    alert('Copied the log link:' + copyText.value);
    console.log('F');
  }

<a pTooltip="Click to copy to clipboard" style="cursor:pointer" id ="HI WASSUP" value="HI WASSUP" click="myFunction()"> Copy Text </a>
nolanite1
  • 153
  • 1
  • 2
  • 10

0 Answers0