# 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.

Source: https://ngwr.dev/reference/directives/copy-to-clipboard  
Kind: Directive

## Import

```angular-ts
import { WrCopyToClipboard } from 'ngwr/directives';
```

## Usage

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

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `[wrCopyToClipboard]` | Copies the bound string on host click. `(copied)` / `(copyFailed)` outputs. | `string` | `—` |

## See also

- [WrClipboard](https://ngwr.dev/reference/services/clipboard) — Programmatic read + write API — what to reach for when you don't want a host-click directive.
