angular how to copy text with button

JavaScript
navigator.clipboard.writeText(content).then().catch(e => console.error(e));copyToClipboard(item): void {
    let listener = (e: ClipboardEvent) => {
        e.clipboardData.setData('text/plain', (item));
        e.preventDefault();
    };

    document.addEventListener('copy', listener);
    document.execCommand('copy');
    document.removeEventListener('copy', listener);
}

Source

Also in JavaScript: