ng2-image-upload
ng2-image-upload copied to clipboard
Delete Image Error
When Image Limit completed, then only the clear button is visible. If I remove all the images or A single image, I'm getting an error from the component. Also, delete event is not fired.
UploadDocumentComponent.html:18 ERROR TypeError: Cannot read property 'nativeElement' of undefined at ImageUploadComponent.deleteAll (image-upload.component.js:85) at Object.eval [as handleEvent] (ImageUploadComponent.html:27) at handleEvent (core.js:13589) at callWithDebugContext (core.js:15098) at Object.debugHandleEvent [as handleEvent] (core.js:14685) at dispatchEvent (core.js:10004) at eval (core.js:10629) at HTMLButtonElement.eval (platform-browser.js:2628) at ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:4751)
Yes same issue here... I don't know it's good practice or not (of course not :) ) but it solved my issue by commenting out this line in ImageUploadComponent.prototype.deleteFile
this.inputElement.nativeElement.value = '';
in
/node_modules/angular2-image-upload/lib/image-upload/image-upload.component.js
@majidnk01 Obviously its not a good approach, when you are working remote. It will solve my current development problem but will cause problem for others.
Same issue on Angular 6 with your last version.
I found a workaround for this issue, just call contents of deleteAll()
method directly in your code:
...
@ViewChild('logoUploader') logoUploader: ImageUploadComponent;
...
// this.logoUploader.deleteAll();
this.logoUploader.files.forEach(f => this.logoUploader.removed.emit(f));
this.logoUploader.files = [];
this.logoUploader.fileCounter = 0;
...
the same here
I've the same problem. Think had resolved this problem but no published in the npm yet.
Publish it on npm, please
@aberezkin , @UncleDave Can you please publish this update?
I'm having the same issue and it hasn't been published on npm yet!
Same here +1 however only when the [max]
property is set. If this is left off then it works fine?!
The problem is the parameter [max]="xxxxx" I solve my problem, remove the parameter and add the parameter [beforeUpload]="onBeforeUpload". private fileCounter = 0;
onBeforeUpload = (metadata: UploadMetadata) => { if (this.fileCounter >= xxx) { metadata.abort = true; } else { this.fileCounter++; } return metadata; };
Publish it on npm, please
facing same issue. Please update !
And after one picture removing, If we select new picture nothings happens afterwards. Please fix this issue.
+1
Having same issue