我的HTML:
<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获得价值的错误。
答案 0 :(得分:0)
您想为输入使用双向绑定吗?如果是这样,您需要使用<input [(ngModel)]="coverage.id">
之类的内容。您可以查看此文档https://angular.io/docs/ts/latest/guide/template-syntax.html