angular-editor-toolbar component crashes after successful file upload
See original GitHub issueHi,
I get following error when I succesfully upload an image:
ERROR TypeError: Cannot read property 'nativeElement' of undefined at AngularEditorToolbarComponent.fileReset (angular-editor-toolbar.component.ts:339)
The problem is that myInputFile is always (ViewChild: fileInput) undefined.
So here:
onFileChanged(event) { /** @type {?} */ const file = event.target.files[0]; if (file.type.includes('image/')) { if (this.uploadUrl) { this.editorService.uploadImage(file).subscribe((/** * @param {?} e * @return {?} */ e => { if (e instanceof _angular_common_http__WEBPACK_IMPORTED_MODULE_1__["HttpResponse"]) { **this.editorService.insertImage(e.body.imageUrl); this.fileReset();** } })); } else { /** @type {?} */ const reader = new FileReader(); reader.onload = (/** * @param {?} e * @return {?} */ (e) => { /** @type {?} */ const fr = (/** @type {?} */ (e.currentTarget)); this.editorService.insertImage(fr.result.toString()); }); reader.readAsDataURL(file); } } }
when calling:
fileReset() { this.myInputFile.nativeElement.value = ''; }
myInputFile does not exist.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top GitHub Comments
Until new release to fix this issue: goto node_modules/@kolkov/angular-editor/ivy_ngcc/fesm2015/kolkov-angular-editor.js and do the followings:
if (e instanceof HttpResponse) { this.editorService.insertImage(e.body.imageUrl); // this.fileReset(); //comment out his line event.srcElement.value = null; // add this line } //comment this section of the code // /** // * Reset Input // * @return {?} // */ // fileReset() { // this.myInputFile.nativeElement.value = ‘’; // }
Hi! Thanks for reporting this issue. I will try to reproduce this situation.