I would like to use https://github.com/kolkov/angular-editor, but there is a problem: I want to upload images, this seems to work fine, request to/from backend looks good.
There is an ElementRef myInputFile
:
myInputFile: [{ type: _angular_core__WEBPACK_IMPORTED_MODULE_0__["ViewChild"], args: ['fileInput', { static: true },] }]
that's connected to fileInput
:
<input
style="display: none"
accept="image/*"
type="file" (change)="onFileChanged($event)"
#fileInput>
onFileChanged
is implement something like this:
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);
}
}
}
So at some point this.fileReset()
is being called
fileReset() {
this.myInputFile.nativeElement.value = '';
}
Any Ideas?