ionic2-meteor icon indicating copy to clipboard operation
ionic2-meteor copied to clipboard

bug:Toggle issues

Open slippyC opened this issue 8 years ago • 2 comments

If you do an [(ngModel)] on a toggle, it gets out of sync. In Firefox it does exactly opposite. You can do a console.log on whatever var you are using and it will be opposite. In Chrome it gets out of sync. If you flick it quick enough, it will sync back up sometimes.

ex: Toggle will be true, var will be false...

slippyC avatar Mar 27 '16 23:03 slippyC

Same issue with <ion-checkbox>...

Are other people having this issue?

slippyC avatar Apr 14 '16 18:04 slippyC

Figured out how to deal with this, at least in initial tests. It wasn't obvious, at least to me, that there is a directive you use on <ion-toggle> and I assume <ion-checkbox>as well.

(change) event does not work on a toggle only (click). (click) seemed like the only option.

So doing it this way: <ion-list> <ion-item> <ion-label>Toggle Button</ion-label> <ion-toggle [(ngModel)]="someVar" (click)="someFunc()"></ion-toggle> </ion-item> </ion-list> Is not going to have the desired effect!

You would need to do it like this: <ion-list> <ion-item> <ion-label>Toggle Button</ion-label> <ion-toggle [(ngModel)]="someVar" [change]="someFunc()"></ion-toggle> </ion-item> </ion-list>

You will get inconsistent values on the control if you try to use (click). You need to use the [change] directive instead!!!

Hope this helps someone that runs into this problem...

BTW, this has nothing to do with Barbatus's implementation. This is an Ionic v2 thing...

slippyC avatar Apr 25 '16 22:04 slippyC