Background: In one of my tables, there is a column where users can either choose or upload files as input. I have implemented a feature that allows users to select multiple files at once.
Issue at Hand: What I am trying to achieve is to have an 'x' symbol, a close button, or a delete option next to each filename after selecting multiple files (let's say 3 as an example). This way, users can easily unselect or delete individual files as needed. I have included a visual example for clarity.
Additionally, I am seeking advice on how to remove specific list values by index.
If my explanation is unclear, please leave a comment below.
HTML Code Snippet:
<td>
<ng-container>
<input style="width:240%" type="file" id="file" multiple
(change)="getFile($event)" >
</ng-container>
</td>
Typescript Code Snippet:
myFiles:string [] = [];
getFile (e) {
for (var i = 0; i < e.target.files.length; i++) {
this.myFiles.push(e.target.files[i]);
}}
I have included a link to my Stackblitz project for further assistance:
Stackblitz: https://stackblitz.com/edit/angular-ivy-4vnwed?file=src%2Fapp%2Fapp.component.ts