我在桌子上工作。表格的一列具有复选框。当我单击一个复选框时,该列的所有复选框都会被选中。
这是我的代码
<td>
<label class="container">
<input type="checkbox" [(ngModel)]="theCheckbox" data-md-icheck (change)="toggleVisibility($event)"/>
Checkbox is <span *ngIf="marked">checked</span><span *ngIf="!marked">unchecked</span>
</label>
</td>
toggleVisibility函数为空
toggleVisibility(data)
{
}
我该如何解决这个问题?
尝试这样的事情:
<table >
<thead>
<tr>
<th *ngFor="let head of headElements" scope="col">{{head}} </th>
</tr>
</thead>
<tbody>
<tr *ngFor="let el of elements;let index = index;">
<th scope="row">{{el.id}}</th>
<td>{{el.first}}</td>
<td>{{el.last}}</td>
<td>
<input type="checkbox" [(ngModel)]="el.checked" >
<span *ngIf="el.checked" >checked</span>
</td>
</tr>
</tbody>
</table>
https://stackblitz.com/edit/angular-mnrmpp?file=src/app/app.component.html
希望能帮助到你!
根据我的.ts文件中的代码,如何获取选定的记录。谢谢
stackblitz.com/edit/angular-tmd8r9?file=src/app / ...