Html2canvas: How can I use html2canvas with Angular 2?

Created on 17 Oct 2016  路  6Comments  路  Source: niklasvh/html2canvas

Can someone please explain how to use html2canvas properly with Angular 2?

It can be installed with npm install html2canvas but it does not contain any TypeScript code.
@niklasvh , will you provide a version we can easily use with Angular 2?

Most helpful comment

I'm using with Ionic2 + Angular 2.

import * as html2canvas from 'html2canvas';

And use like:

myClickFunction( event: any ){
  html2canvas( event.target )
    .then((canvas) => {
      console.log( canvas );
    })
    .catch(err => {
      console.log("error canvas", err);
    });
}

All 6 comments

Check this answer
Here

Any news please? did someone fix this issue?

@Tarek-Adra Sorry that link didn't work for me.

/Applications/MAMP/htdocs/html5-banner/src/app/selected-banner/selected-banner.component.ts (64,10): Argument of type '{ onrendered: (canvas: any) => void; }' is not assignable to parameter of type 'Html2CanvasOptions'.
  Object literal may only specify known properties, and 'onrendered' does not exist in type 'Html2CanvasOptions'.

I'm using with Ionic2 + Angular 2.

import * as html2canvas from 'html2canvas';

And use like:

myClickFunction( event: any ){
  html2canvas( event.target )
    .then((canvas) => {
      console.log( canvas );
    })
    .catch(err => {
      console.log("error canvas", err);
    });
}

I am trying this in Angular 4 and I get below error:
Uncaught (in promise): Error: Can't resolve all parameters for ImageService: (?).
I have installed the typings from "@types/html2canvas"

@jaichandra
I am also seeing something similar using Angular 5. Trying to build a minimum test case at the moment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rrutkows picture rrutkows  路  4Comments

koreanman picture koreanman  路  4Comments

dking3876 picture dking3876  路  4Comments

anthonymejia picture anthonymejia  路  4Comments

diego-rey picture diego-rey  路  3Comments