Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular compilation fails --- Can't resolve all parameters for html2canvas: (?, ?) #2485

Closed
1 of 2 tasks
specialsagar opened this issue Feb 16, 2021 · 0 comments
Closed
1 of 2 tasks

Comments

@specialsagar
Copy link

specialsagar commented Feb 16, 2021

  • You are using the latest version
  • You are testing using the non-minified version of html2canvas and checked any potential issues reported in the console

Bug reports:

Running into compilation issue for angular 8.
When I run unit testing for my component, it gives the following error:-

	Failed: Can't resolve all parameters for html2canvas: (?, ?).
	error properties: Object({ ngSyntaxError: true })
	Error: Can't resolve all parameters for html2canvas: (?, ?).
	    at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
	    at CompileMetadataResolver._getDependenciesMetadata (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:20401:1)
	    at CompileMetadataResolver._getTypeMetadata (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:20296:1)
	    at CompileMetadataResolver._getInjectableTypeMetadata (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:20514:1)
	    at CompileMetadataResolver.getProviderMetadata (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:20523:1)
	    at providers.forEach (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:20461:1)
	    at <Jasmine>
	    at CompileMetadataResolver._getProvidersMetadata (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:20421:1)
	    at CompileMetadataResolver.getNgModuleMetadata (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:20148:1)
	    at JitCompiler._loadModules (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25824:1)

The code I'm using for my component:-

import html2canvas from 'html2canvas';

...

onSave() {
      html2canvas(document.body, <any>options).then(canvas => {
        canvas.id = 'bs-printed-canvas';
        document.getElementById('canvas-container').appendChild(canvas);
        this.generatePDF(canvas.toDataURL('image/png'));
      });
}

I have also tried using below ways of loading the library but still gives the same error.

import * as  html2canvas from 'html2canvas';

Specifications:

  • html2canvas version tested with: 1.0.0.rc7
  • Browser & version: Chrome - Version 88.0.4324.104
  • Operating system: Windows 10
@niklasvh niklasvh closed this as completed Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants