copy text to clipboard angular code example
Example 1: copy to clipboard angular
navigator.clipboard.writeText(content).then().catch(e => console.error(e));
Example 2: angular how to copy text with button
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);
}