[英]Angular2 - How to put TextBox in *ngFor
我正在嘗試在*ngFor
Like中放置一個文本框
<tr *ngFor="let abc in _Apple">
<td>{{abc.Name}}</td>
<td> <input matInput name="UnitofPrice" [(ngModel)] = "UnitofPrice">
</td>
<td>{{UnitofPrice}}</td>
如果我在UnitofPrice
輸入任何內容,它將反映所有內容。 我該如何刪除?
使用ngFor的索引使NG模型唯一。請參見示例:
<tr *ngFor="let abc in _Apple; let i = index;">
<td>{{abc.Name}}</td>
<td> <input matInput name="UnitofPrice" [(ngModel)]="abc[i]">
</td>
<td>{{UnitofPrice}}</td>
在您的按鈕或Submit函數中將其作為參數傳遞,例如:
<button (click)="yourFunc(abc[i])">submit</button>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.