So I have the following html:
<label class="form-group" i18n>Send us your email:</label> <span (click)="select_email()" id="select_email">XYI.runme@previews.emailaddress.com</span>
and the following method in my *.component.ts file:
select_email() {
var select_email = <HTMLSpanElement> document.getElementById('select_email');
select_email.select();
var successful = document.execCommand('copy');
console.log("copy to clipboard was successful? " + successful);
}
However, when it tries to compile, I get the error message that .select() does not exist on HTMLSpanElement. I have tried forcing the type to HTMLElement as well and I get the same results.
Is there a way to select the text inside the span element using Angular/typescript? I am not allowed to use jQuery, so only pure javascript/typescript is allowed.