Here is the html code I am working with:
<label class="form-group" i18n>Send us your email:</label> <span (click)="select_email()" id="select_email"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cb939282e5b9be">[email protected]</a></span>
In my *.component.ts file, I have the following method:
select_email() {
var select_email = <HTMLSpanElement> document.getElementById('select_email');
select_email.select();
var successful = document.execCommand('copy');
console.log("Was copying to clipboard successful? " + successful);
}
However, I encounter an error during compilation stating that .select() does not exist on HTMLSpanElement. I have also tried using HTMLElement as the type but face the same issue.
Is there a way to select the text within the span element using Angular/typescript without relying on jQuery? Pure javascript/typescript solutions are preferred.