cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

EXCEPTION: Cannot set property 'original' of undefined #133

Open firaskudsy opened 7 years ago

firaskudsy commented 7 years ago

I tried to use the Customizing Image cropper code, but am getting this error

EXCEPTION: Cannot set property 'original' of undefined

Any Idea ?

akliuiko commented 7 years ago

Maybe you don't use Image field in your component? This is a workaround for now.

cstefanache commented 7 years ago

Can you please paste a snippet on how are you using it?

akliuiko commented 7 years ago

Of course. I noticed that this error takes place in case when you don't use image variable as your component class member It can be fixed with following snippet:

Image: any; // declare as component class member
//...
fileChangeListener($event) {
     this.Image = new Image();
     //...
    var that = this;
    myReader.onloadend = function (loadEvent:any) {
        that.Image.src = loadEvent.target.result;
        //...
    };
    myReader.readAsDataURL(file);
}
wmattei commented 6 years ago

solved?