我正在尝试使用angular4更新我的数据。但是,如果我点击更新按钮,那么如何获取所有选定的值会有点困难。
`
<table>
<tr *ngFor="let parts of info" class="text-center">
<td>{{parts.modelD}}</td>
<td>{{parts.start}}</td>
<td>{{parts.end}}</td>
<td><input type="text" class="form-control" name="editable_good_parts" id="editable_good_parts" value="{{parts.good_parts}}" style="max-width:100; text-align:center;"/></td>
<td><input type="checkbox" name="row_id" value="{{parts.id}}" [checked]="isSelected"/></td>
</tr>
</table>
<button type="submit" class="btn btn-info">Update Data</button>
`
答案 0 :(得分:0)
<table>
<tr *ngFor="let parts of info" class="text-center">
<td>{{parts.modelD}}</td>
<td>{{parts.start}}</td>
<td>{{parts.end}}</td>
<td><input type="text" class="form-control" name="editable_good_parts" id="editable_good_parts" value="{{parts.good_parts}}" style="max-width:100; text-align:center;"/></td>
<td><input type="checkbox" name="row_id" **[value]="parts.id"** [checked]="isSelected"/></td>
</tr>
</table>
<button type="submit" class="btn btn-info">Update Data</button>
</table>
只需使用绑定值属性结帐(例如。[value] =&#34; myData&#34;)