首页 > 解决方案 > 带复选框的离子表

问题描述

我想知道如何做类似的事情: https://bootsnipp.com/snippets/featured/bootstrap-snipp-for-datatable in an ionic-angular app without using jQuery。谢谢。

标签: angularionic-frameworkionic3

解决方案


你的意思是全选/全选?

<ion-checkbox (ionChange)="selectAll()" [(ngModel)]="selectAllChecked"></ion-checkbox>
<ng-template ngFor let-item [ngForOf]="rows">
    <ion-checkbox [(ngModel)]="item.checked"></ion-checkbox>
</ng-template>
//js
public selectAllChecked = false;
public rows=[{},{},{}];
selectAll() {
    if (this.selectAllChecked) {
        this.rows.map(item => item.checked = true);
    } else {
        this.rows.map(item => item.checked = false);
    }
}

推荐阅读