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.

5
  • please provide complete ts file with the libraries you are using Commented Nov 15, 2019 at 5: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" Commented Nov 15, 2019 at 6:24
  • The above mentioned are the libraries that I am using. Do we to add any other specific package for using ClipboardItem Commented Nov 15, 2019 at 6:26
  • @Kaiido I am trying to implement link. 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'. Commented Nov 15, 2019 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]); Commented Nov 15, 2019 at 10:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.