Interacting with the clipboard
The Angular CDK library contains a collection of Angular artifacts that we can use to interact with the system clipboard. Specifically, it includes a directive for copying data to the clipboard and an event binding for taking additional action when the content has been copied. Let's see how we can integrate both in our component library, as follows:
- Execute the following command of the Angular CLI to create a new Angular component in the library:
ng generate component copy-button --project=ui-controls --export
- Export the newly generated component from the
public-api.ts
file, as follows:export * from './lib/ui-controls.service'; export * from './lib/ui-controls.component'; export * from './lib/ui-controls.module'; export * from './lib/card-list/card-list.component'; export * from './lib/card'; export * from './lib/copy-button/copy-button.component';
- Open the
ui-controls.module...