0

Getting the error error TS2304: Cannot find name 'ClipboardItem' when trying to create ClipboardItem for navigator.clipboard.write().

const clipboardItemInput = new ClipboardItem({'image/png' : blobInput}); await navigator.clipboard.write([clipboardItemInput]);

I am using Angular CLI: 6.0.5, Angular: 6.0.3 for building.

TTT
  • 11
  • 4
  • please provide complete ts file with the libraries you are using – Plochie Nov 15 '19 at 05:17
  • "@angular/animations", "@angular/cdk", "@angular/common", "@angular/compiler", "@angular/core", "@angular/flex-layout", "@angular/forms", "@angular/http", "@angular/material", "@angular/platform-browser", "@angular/platform-browser-dynamic", "@angular/router", "@ngx-translate/core", "@ngx-translate/http-loader", "@types/pako", "@types/three", "angular2-draggable", "core-js", "css-element-queries", "hammerjs", "ng2-tooltip-directive", "ngx-clipboard", "ngx-color-picker", "pako", "rxjs", "systemjs", "three", "three-orbitcontrols-ts", "typings", "zone.js" – TTT Nov 15 '19 at 06:24
  • The above mentioned are the libraries that I am using. Do we to add any other specific package for using **ClipboardItem** – TTT Nov 15 '19 at 06:26
  • @Kaiido I am trying to implement [link](https://jsfiddle.net/0794oysr/2/). When I implemented your solution I am getting the error : `TypeError: Failed to execute 'write' on 'Clipboard': Iterator getter is not callable`. After solving it I am getting: `TypeError: Failed to execute 'write' on 'Clipboard': Failed to convert value to 'ClipboardItem'.` – TTT Nov 15 '19 at 10:27
  • My Code: `let newVariable: any; newVariable = window.navigator; const url = canvas.toDataURL(); const blobInput = await this.loadBlob(url); const dT = new DataTransfer(); dT.items.add(new File([blobInput], 'filename', { type: 'image/png' })); await newVariable.clipboard.write([dT]);` – TTT Nov 15 '19 at 10:42

0 Answers0