【发布时间】:2018-10-14 17:35:58
【问题描述】:
这是我的代码,一旦选中/取消选中全选离子选项,我想使用它来检查/取消选中我的选择弹出窗口中的所有选项。
items:any =[
{id:1, value:"Apple"}
{id:2, value:"Banana"}
{id:3, value:"Stawberry"}
{id:4, value:"PineApple"}
{id:5, value:"Grapes"}
];
selectedItems:any;
selectAll:boolean;
/**
* This select all the items in the ion-select popup
**/
selectAllItems() {
if(!selectAll) {
this.items.filter(Obj => {
this.selectedItems.push(Obj.id);
});
this.selectedItems.push(0);
this.selectAll = true;
} else {
this.selectedItems = this.items[0].id;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<ion-item>
<ion-label>Multiselect</ion-label>
<ion-select [(ngModel)]="selectedItems">
<ion-option (ionSelect)="selectAllItems()" [value]="0">
Select All
</ion-option>
<ion-option *ngFor="let item of items" [value]="item.id">
{{item.value}}
</ion-option>
</ion-select>
</ion-item>
【问题讨论】:
标签: typescript ionic3 angular5