javascript - How to use ngModel in ion-checkbox? -


i'm trying use ngmodel, ngmodel doesn't work there. code:

<ion-checkbox *ngfor="#item of items" [(ngmodel)]="item.checked">   {{item.name}} </ion-checkbox> 

but error:

exception: expression 'checked in addinterestitem@5:2' has changed after checked. previous value: 'false'. current value: 'false' in [checked in addinterestitem@5:2]

example data:

this.items = [    {name: 'dancing', checked: false},    {name: 'jazz', checked: false},    {name: 'metal', checked: true},    {name: 'pop', checked: false},    {name: 'rock\'n\'roll', checked: false},    {name: 'folk metal', checked: true}  ]; 

i not familiar <ion-checkbox>. when tried repeat story normal <input type="checkbox" />, couldn't success applying ngfor input type="checkbox" directly. did, took <ul><li *ngfor="#item of items" > , put input type="checkbox" within , started working expected.

i feel myanswer further.

doesn't work in mycase

<input  type="checkbox" *ngfor="#item of items" [(ngmodel)]="item.checked" />{{item.name}}   /* don't know error occurs. can check plunkr modifying it/*. 

worked properly

    <ul>         <li *ngfor="#item of items">{{item.name}}             <input type="checkbox" [(ngmodel)]="item.checked" />         </li>     </ul> 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -