I am trying to dynamically set the name attribute to my input fields I have in a data table in Angular inside of an *ngFor. However, I am seeing when I go to console.log the event of in my filter method on keyup in the fields, there is no name being set for each input. How do add these names dynamically?
table.component.html
<table>
<thead>
<tr>
<th *ngFor="let col of cols"
(click)="selectColHeader(col.prop);
col.enableSort && sort(col.prop)"
role="button">
<label>{{col.header}}</label>
<input type="text"
aria-label="search text field"
name="{{col.header}}" <-- not being set
ngModel
placeholder="search..."
(click)="$event.stopPropagation()"
(keyup)="filterData($event)"
*ngIf=col.enableFilter/>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let row of data |
filter: fields:selectedInput |
paginate: { itemsPerPage: 6, currentPage: page, id: id }">
<td *ngFor="let col of cols">
{{row[col.prop]}}
</td>
</tr>
</tbody>
</table>
table.component.ts
filterData(e){
console.log(e.target.name) <--- name is a blank string
console.log(e)
this.fields = e.target.value
}