How to get input values from a variable-length table

Discussão em 'Angular' iniciado por Tim, Novembro 11, 2024.

  1. Tim

    Tim Guest

    I have an Angular app that has a variable-length table in which I want the user to be able to enter input values for each row.

    This is the bare-bones of what I'm trying to do.

    After user has selected several files from a p-fileUpload, I want to be able to display each file in a table and allow them to add additional data (metadata) for each record.

    <tbody>
    <tr *ngFor="let file of files; let ii = index">
    <td>{{ file.name }}</td>
    <td>{{ file.size }}</td>
    <td>{{ file.type }}</td>
    <td>
    <!--Would like to be able to grab this value here-->
    <input type="text" placeholder="Enter Title">
    </td>
    </tr>
    </tbody>


    I think this should be relatively simple, but so far I haven't been able to come up with a solution. If I try to do it by assigning a formControlName or an ngModel to the text input those don't really work because they're intended for a single input component rather than one of several in a table.

    Is there any way to assign the input in each row its own unique identifier and then grab the value in the ts file?

    Thanks!

    Continue reading...

Compartilhe esta Página