import { Component } from '@angular/core';
import { WrButton } from 'ngwr/button';
import { WrCopyToClipboard } from 'ngwr/directives';
@Component({ imports: [WrButton, WrCopyToClipboard] })
export class MyComponent {}wrCopyToClipboard
Copy a string to the clipboard when the element is clicked.
Installation
Import the class, and @use the entry point in your global styles: without it the component renders unstyled.
Usage
(copied) fires once the text is on the clipboard. A refusal emits (copyFailed).
<button [wrCopyToClipboard]="value" (copied)="toast('Copied!')">Copy</button>API
| Name | Description | Type | Default |
|---|---|---|---|
[wrCopyToClipboard]required | The string copied on host click. Required. | string | — |
(copied) | The text that reached the clipboard. | string | — |
(copyFailed) | What the write threw, such as a denied permission. | unknown | — |