Angular : How to Add/Remove Files in the Angular?

前端 未结 5 1549
旧巷少年郎
旧巷少年郎 2021-01-18 10:11

Here i choose multiple images and shows using *ngFor And there I have placed a delete button which is appear in the screenshot, click on delete button i want to

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 10:45

    In your html code

     
          
        

    //this is your ts code

    onSelectFile(event) {
    if (event.target.files && event.target.files[0]) {
      var filesAmount = event.target.files.length;
      for (let i = 0; i < filesAmount; i++) {
        var reader = new FileReader();
    
        reader.onload = (event: any) => {
          this.imageurls.push({ base64String: event.target.result, });
         }
        reader.readAsDataURL(event.target.files[i]);
        }
      }
     }
    

    For more details:https://findandsolve.com/articles/how-to-upload-and-remove-multiple-image-using-anular-code-example

提交回复
热议问题