multiple image is implemented

This commit is contained in:
병준 박 2019-12-03 19:06:29 +09:00
parent b0e2b12b09
commit 8dbd747f16

View File

@ -61,14 +61,17 @@ export class WriteComponent implements OnInit, OnDestroy, AfterViewInit {
onClickImage() {
this.fileInput.nativeElement.click();
const self = this;
this.fileInput.nativeElement.onchange = () => {
this.fileInput.nativeElement.onchange = async () => {
const fileList: FileList = self.fileInput.nativeElement.files;
FileUtil.fromBlobToDataUrl(fileList.item(0)).then(dataUrl => {
for (let i = 0; i < fileList.length; i++) {
const file = fileList.item(i);
const dataUrl = await FileUtil.fromBlobToDataUrl(file);
const img = document.createElement('img');
img.src = dataUrl as string;
self.insertNode(img);
});
}
self.fileInput.nativeElement.value = '';
};