Hi, is it possible to bind an ngModel array to a list of checkbox
// in controller
this.myDataArray = [ 2 ];
this.myEntries = [
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 3' },
{ id: 3, name: 'Item 2' },
];
// in template
<ion-list>
<button ion-item
*ngFor="let option of myEntries;" >
<ion-label>{{ option.name }}</ion-label>
<ion-checkbox item-right [(ngModel)]="myDataArray" value="{{ option.id }}"></ion-checkbox>
</button>
</ion-list>
// result
- Item 1 [ ]
- Item 2 [x]
- Item 1 [ ]
So each time one is checked, it’s added to myDataArray
, and removed if unchecked.