Directive

wrCopyToClipboard

Copies the bound string on host click. navigator.clipboard.writeText where it exists, with a hidden-textarea + execCommand recovery for non-secure contexts. (copied) fires only once the write actually lands; a refusal — denied permission, an unfocused document, no clipboard at all — is a (copyFailed), never a silent success, and focus goes back to whatever held it before the fallback selected its textarea.

Import

import { WrCopyToClipboard } from 'ngwr/directives';

Usage

<button [wrCopyToClipboard]="value" (copied)="toast('Copied!')">Copy</button>

API

NameDescriptionTypeDefault
[wrCopyToClipboard]Copies the bound string on host click. (copied) / (copyFailed) outputs.string

See also