Reputation: 12025
Why this code is not working:
model:any = {};
<tr *ngFor="let item of items">
<td><input [ngModel]="model[id]" size="7" /></td>
</tr>
It says there is no id
inside model
. How to use ngModel
properly in *ngFor
?
Upvotes: 0
Views: 61
Reputation: 22203
Try like this:
TS:
model = [];
Template:
<input size="7" (change)="model[item.id]=$event.target.value"/>
Upvotes: 1