bsCopy copies the bound value to the system clipboard when the host element is clicked. Listen for (bsCopied) to confirm the action — useful for triggering a toast or off-canvas notice.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>I'm the title</title>
</head>
<body>
<p>I'm the content</p>
</body>
</html>
You might also use the @angular/cdk for this.
<button [bsCopy]="textToCopy" (bsCopied)="onCopied()">Copy</button>
import { Component } from '@angular/core';
import { BsCopyDirective } from '@mintplayer/ng-bootstrap/copy';
@Component({
selector: 'my-copy-demo',
templateUrl: './my-copy-demo.component.html',
imports: [BsCopyDirective],
})
export class MyCopyDemoComponent {
protected textToCopy = 'Hello world';
onCopied() {
console.log('Copied to clipboard');
}
}