ng2-clipboard
a simple component and service for copying text to the user's clipboard.
installation:
npm i --save ts-clipboardnpm i --save ng2-clipboard
usage:
angular-seed (mgechev) project
importing inproject.config.ts:
let additionalPackages: ExtendPackages[] = [{
name: 'ng2-clipboard',
path: 'node_modules/ng2-clipboard/index.js'
},
{
name: 'ng2-font-awesome',
path: 'node_modules/ng2-font-awesome/index.js'
},
{
name: 'ts-clipboard',
path: 'node_modules/ts-clipboard/ts-clipboard.js'
}];
this.addPackagesBundles(additionalPackages);
systemjs builder
bundling withimporting the module
import { ClipboardModule } from 'ng2-clipboard';
...
#### ClipboardComponent
all of the below usages are valid:
```html
<clipboard-component [content]="someText" [faIcon]="true"></clipboard-component>
<br/>
<clipboard-component [content]="someText" [img]="'assets/img/terribleIcon.png'" [altText]="'copy to clipboard'"></clipboard-component>
<br/>
<clipboard-component [content]="someText" [text]="'click to copy'" [altText]="'copy to clipboard'"></clipboard-component>
<br/>
<clipboard-component [content]="someText" [img]="'assets/img/terribleIcon.png'" [faIcon]="true" [text]="'click to copy'"></clipboard-component>
<br/>
}
output
ClipboardService
;;
output
imports:
content: string; // the text to be copiedaltText: string = 'copy to clipboard'; // the title / altText to be displayed on mouseover