So, I've tried with already 3 or 4 different ngx-* libraries, that promise to give capability to copy page content to Clipboard. Here's how it goes with ngx-clipboard
, which seems to be the most up-to-date of them all, and promises Angular 10 support.
Steps:
- clone
jhipster-sample-app
- run
.mvnw
, thennpm start
- run
npm install ngx-clipboard --save
- add the module to imports, in
app.module.ts
:
import { ClipboardModule } from 'ngx-clipboard';
...
imports: [
...
ClipboardModule,
...
]
- added data model field to
home.component.ts
:
fakeValue = 'hi clipboard';
- added input and button to
home.component.html
:
<input type="text" class="form-control" [(ngModel)]="fakeValue"/>
<button ngxClipboard [cbContent]="fakeValue">Copy</button>
- click Save; the project re-build will be triggered, with following errors emitted:
ERROR in src/main/webapp/app/home/home.component.html:30:30 - error NG8002: Can't bind to 'cbContent' since it isn't a known property of 'button'.
30 <button ngxClipboard [cbContent]="fakeValue">Copy</button>
~~~~~~~~~~~~~~~~~~~~~~~
- and of course, "copy" button does not copy anything.
Question: what am I doing wrong?
PS: this branch (https://github.com/62mkv/jhipster-sample-app/tree/ngx-clipboard) contains all of the changes, described above.
PPS: npm run build
emits the same error (+ also error about the template, which is a consequence of the above mentioned error)