Ion-toggle change event not working


#1

Hi,

I would like to know why the “change” event is not triggered when changing the toggle state. What am I missing?

html

<ion-item>
  <ion-label>Toggle state</ion-label>
  <ion-toggle [(ngModel)]="theSate" (change)="stateChange($event)" [checked]="_bState" yellow></ion-toggle>
</ion-item>   

ts

stateChange(event) {
  do something
}

Thanks


#2

I have the same problem. A workaround is to use the (click) event.


#3

try to this (ionChange)="stateChange($event) instead (change)="stateChange($event)


#4

[(ngModel)] is nothing but [ngModel] and (ngModelChange). So you could do this:
<ion-toggle [ngModel]="theSate" (ngModelChange)="stateChange($event)" [checked]="_bState" yellow></ion-toggle>