angular - 带复选框的离子表
问题描述
我想知道如何做类似的事情: https://bootsnipp.com/snippets/featured/bootstrap-snipp-for-datatable in an ionic-angular app without using jQuery。谢谢。
解决方案
你的意思是全选/全选?
<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);
}
}
推荐阅读
- android - 结合 `bylazy` 和 `object` 导致编译器错误“找不到符号”
- angular - 在 angular2 中只构建一个(延迟加载)模块
- android - Android Studio 主题编辑器没有做任何事情
- scala - 我如何从 pyspark 访问 couchbase
- apache-kafka - 添加用户定义的消息转换器后无法自动连接处理器
- javascript - 选中的复选框变成形式
- nginx - 带有斜杠的奇怪 Nginx 行为
- r - R在将变量名称作为字符串提供时评估变量
- node.js - 在heroku上部署Nodejs+Express+React+Webpack应用
- ocaml - 这个 ocaml 代码段是什么意思?