Ion-toggle freezes app with ngModel and ionChange


I am using the latest version of ionic 4.

I am trying to use ion-toggle in the following way:

      <ion-toggle color="warning" [(ngModel)]="testVar" (ionChange)="toggleEvent($event)"></ion-toggle>

When I launch the app (testing in chrome browser) with ionic serve if I try to toggle it will do the first one, but then the entire chrome brower tab running the app freezes up.

If I use the ngModel but remove the ionChange it works continually.

If I use ionChange and remove ngModel it works continually.

Both together do not work.

Any ideas?


My idea would be to use only one or the other. I find it much easier to read, test, and debug programs the more clearly delineated lines of responsibility are drawn. Can you just add the code to modify testVar to toggleEvent() and then make the [ngModel] only an input binding?

You can use it and the following way, and it goes very well.
Change ionChange for ngModelChange

      <ion-toggle color="warning" [(ngModel)]="testVar" (ngModelChange)="toggleEvent($event)"></ion-toggle>

Thank you very much for the reply. That works great!

1 Like