Thursday, 28 March 2019

Copy html to clipboard (Angular)

Is there a way to copy html to clipboard in Angular?

I'm using ngx-clipboard, and trying to format the copied text (i.e., use bold, bullets)

.ts

constructor(private _clipboardService: ClipboardService) {}

callServiceToCopy() {
    this._clipboardService.copyFromContent('<B>This is an important message<\/B>\n These are the details');
}

Component:

<button class="btn btn-primary btn-sm" (click)="callServiceToCopy()">Copy</button>

Stackblitz: https://stackblitz.com/edit/github-ar12tp-irzz84



from Copy html to clipboard (Angular)

No comments:

Post a Comment