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 delete chosen image from chosen list i tried below code but i not getting proper solution.
add.component.html
<button mat-raised-button (click)="fileInput.click()">Select File</button>
<input style="display: none" type="file" (change)="onFileChanged($event)" #fileInput multiple="true">
<div *ngFor="let selected of selectedFile;let index = index">
<h3>{{selected.name}}</h3>
<button mat-icon-button (click)="removeSelectedFile(index)">delete</button>
</div>
add.component.ts
selectedFile: File;
ArrayOfSelectedFile = new Array<string>();
onFileChanged(event : any) {
this.ArrayOfSelectedFile= [];
this.selectedFile = event.target.files;
this.ArrayOfSelectedFile.push(event.target.files);
}
removeSelectedFile(index){
this.ArrayOfSelectedFile.splice(index,1);
}
console.log(this.ArrayOfSelectedFile)after thesplicemethod, does the element got removed ?