How can I preview multiple images that I have selected before uploading them in Angular?
I have managed to do it but only with one image, even though I sele
As shown in this stackblitz, you can store the image URLs in an array and display them with ngFor:
The array of URLs is filled in detectFiles:
export class AppComponent {
urls = new Array();
detectFiles(event) {
this.urls = [];
let files = event.target.files;
if (files) {
for (let file of files) {
let reader = new FileReader();
reader.onload = (e: any) => {
this.urls.push(e.target.result);
}
reader.readAsDataURL(file);
}
}
}
}