Checkbox ngModel from Array

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.

I’m wondering the same thing… Find any answers?

Thanks!

The proposed syntax in the OP makes no sense, because it is binding multiple checkboxes to the same property. If possible, I would build this array at form submission time instead of constantly updating it as checkboxes are checked and unchecked, but either way this is something you are going to have to do in controller code.