3
我有我的HTML:如何設置動態#id(* ngFor)並從Angular2中獲取它的值?
<tr *ngFor="let package of packages">
<td *ngFor="let coverage of coverages">
<input type="hidden" #dynamicID [value]="coverage.id">
<-- Here is one input, maybe put the identifier with the variable package -->
<input #dynamicValue type="text" name="">
<-- Another input, maybe put the identifier with the variable package -->
</td>
<td>
<button type="button" (click)="setPackage(package.id, dynamicID.value, dynamicValue.value)">Guardar</button>
</td>
</tr>
我需要在我的功能setPackage獲得從輸入值。 如果我在輸入中放置相同的#id,則不起作用。總是給我一個無法從undefined獲取價值的錯誤。
這並不回答你的問題,但是由於軟件包和coverage沒有以任何方式連接,因此每個包中的coverage都始終完全相同? – Alex