import { WrClipboard } from 'ngwr/clipboard';WrClipboard
Copy text to the clipboard and read it back.
Installation
Import the class. This entry point has no stylesheet.
Live demo
Copy writes the field; Paste reads the clipboard back.
Usage
private readonly clip = inject(WrClipboard);
const ok = await this.clip.write('Copied!'); // false when no write path worked
const text = await this.clip.read(); // null when unsupported or denied
const state = await this.clip.permission('read'); // 'granted' | 'denied' | 'prompt' | 'unsupported'API
| Name | Description | Type | Default |
|---|---|---|---|
write(text) | Write text. Falls back to execCommand outside a secure context. Resolves true on success. | (text: string) => Promise<boolean> | — |
read() | Read text. Resolves null when unsupported or denied. | () => Promise<string | null> | — |
available() | Whether any write path exists. | () => boolean | — |
permission(name) | Read or write permission. unsupported only when the Clipboard API is missing. | (name: 'read' | 'write') => Promise<WrClipboardPermission> | — |