有一个表,其行是由数组动态形成的。大多数列是是/否特征。数组中的每个特征都有一个选定的值。显示布局时,选中复选框的值取决于选中。提款没有问题。但是我不知道如何进行反向依赖,以便当复选框状态发生变化时,将相应的值输入到对象中。这似乎是一项基本任务,但我花了几个小时都找不到解决方案。这是该表布局的总体图片:
<table class="newnew" [attr.data-vehicles]="1">
<thead>
<tr>
<th *ngFor="let item of arrayObjects">{{item.name}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of arrayObjects; let i = index" [attr.data-index]="i">
<td *ngFor="let item of routeVehicle.vehicleQualities">
<input [attr.data-uuid]="item.uuid" type="checkbox" [checked]="item.selected" (change)="changeCheckbox($event)">
</td>
</tr>
</tbody>
</table>
一次:
此外,在模板中,您需要作为参数而不是事件传递,而是对象本身
item:二: