API reference
Directive selector
The primitive attaches through [tngCopy] or the alias [tngCopyButton] and exports itself as tngCopy for runtime access.
Directive attachment
html
<button
type="button"
tngCopy
[tngCopyText]="payload"
(tngCopied)="onCopied($event)"
></button>
Inputs and outputs
Runtime state
Export the directive instance with #copy="tngCopy" when you need programmatic copy, or when your template wants to react to status(), lastCopiedText(), and error().
Exported runtime API
html
<button
type="button"
tngCopy
#copy="tngCopy"
[tngCopyText]="payload"
>
Copy payload
</button>
@if (copy.status() === "success") {
<p>Copied {{ copy.lastCopiedText() }}</p>
}
await copy.copy();