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

when i give set a default image ,it show Cannot read property 'cropper' of undefined #276

Open
gaona233 opened this issue Dec 21, 2017 · 1 comment

Comments

@gaona233
Copy link

it shows Cannot read property 'cropper' of undefined

i give the default imageurl

let image: HTMLImageElement = new Image();
                image.crossOrigin = 'anonymous';
                this.cropper.settings = this.cropperSettings;
                let thatCroper = this.cropper;
                image.onload = () => {
                    thatCroper.setImage(image);
                    if (!this.cropper) {
                        this.cropper = thatCroper;
                    }
                };
                image.src = this.wallpaperCollection.Cover;
  fileChangeListener($event) {
        this.eventFile = $event;
        this.data1 = {};
        let image: any = new Image();
        let file: File = $event.target.files[0];
        let myReader: FileReader = new FileReader();
        let that = this.cropper;
        this.fileName = file.name;
        myReader.onloadend = function (loadEvent: any) {
            image.src = loadEvent.target.result;
            that.cropper.setImage(image);

        };
        myReader.readAsDataURL(file);
    }

i have no ideal

@anouarcharif
Copy link

Hello,

Instead of this:
let that = this.cropper;

Write this:
let that = this;

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