Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ngx-copypaste

JsDaddy1kMIT19.0.1TypeScript support: included

null

ng2-copypaste, ngx-copypaste, ng2, ng, angular-copypaste, copypaste, angular, angular2, angular2-clipboard, ng2clipboard, jsdaddy, angular-clipboard, clipboard, angular2-clipboard, ng2clipboard, ng2-clipboard, ngx-clipboard

readme

NGX COPYPASTE

NGX COPYPASTE is the best directive to copy any content on any element

CI npm npm downloads

npm

GitHub contributors

GitHub stars

You can also try our NGX MASK check it. You can also try our NGX LOADER INDICATOR check it.

You can try live demo with examples.

Installing

npm

$ npm install --save ngx-copypaste

bun

$ bun install --save ngx-copypaste

Quickstart if ngx-copypaste version >= 15.0.0

Pay attention this version works for angular >= 14.0.0

Import ngx-copypaste directive to your standalone component

@Component({
  selector: 'ngx-component',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
  standalone: true,
  imports: [
    (...)
    NgxCopyPasteDirective,
    (...)
  ],
})
export class AppComponent {
    (...)
}

Quickstart if ngx-copypaste version < 15.0.0

Pay attention this version works for angular < 15.0.0

Import ngx-copypaste module in Angular app.

import {NgxCopyPasteModule} from 'ngx-copypaste'

(...)

@NgModule({
  (...)
  imports: [
    NgxCopyPasteModule
  ]
  (...)
})

Usage

From input

<input type="text" ngxCopyPaste #cp="copy" />

<button (click)="cp.copy()">Copy</button>

From any HTML tag

<p ngxCopyPaste #cp="copy">Lorem ipsum</p>

<button (click)="cp.copy()">Copy</button>

From complex div

<div ngxCopyPaste #cp="copy">
    <h1>Lorem ipsum</h1>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam rutrum augue at ante
        sollicitudin posuere. Pellentesque congue consequat enim quis luctus.
    </p>
    <div>
        <h2>Lorem ipsum</h2>
    </div>
</div>

<button (click)="cp.copy()">Copy</button>

Also you can bind it to any tag

<p ngxCopyPaste #cp="copy">Lorem ipsum</p>

<p (click)="cp.copy()">Copy</p>

Output success cb

<p ngxCopyPaste #cp="copy" (successCb)="copy()">Lorem ipsum</p>

<p (click)="cp.copy()">Copy</p>

public copy(): void { your code }

changelog

19.0.1(2025-04-29)

Feature

  • update dependencies

19.0.0(2024-11-21)

Feature

  • update ng 19.x

18.0.4(2024-10-25)

Feature

  • add tailwind
  • change interface to type, remove prefix "I"
  • update dependencies
  • add ESLint strict rules

17.3.2(2024-03-29)

Feature

  • change decorators to signals

17.0.0(2023-11-28)

Feature

  • update ng 17.x

16.0.1(2023-07-07)

Feature

  • add success cb
  • update dependencies

16.0.0(2023-07-07)

Feature

  • update ng 16.x

15.0.0(2022-25-12)

Feature

  • ng 15