Ion-toggle's ionChange property triggers on every view load


#1

Is there a bug on Ionic 2 RC3 at the moment whereby an ion-toggle or an ion-checkbox element is triggering their ionChange functions whenever a new page loads? Here is a simple example of the kind of code that I am dealing with in my view file:

<ion-list>
  <ion-item *ngFor="let type of software">
    <ion-label>{{type.name}}</ion-label>
    <ion-checkbox [disabled]="!type.onOffState" checked="type.onOffState" [(ngModel)]="type.onOffState" (ionChange)="checkboxChange(type.categoryId, type.categoryName, $event.checked)"></ion-checkbox>
 </ion-item>
</ion-list>

Every time I run the settings.ts page where this code is running, it triggers the event in the (ionChange) attribute.


#2

Is there a reason you’re using ionChange instead of click?


#3

Well I couldn’t seem to return the checkbox/toggle’s selected state when I used click. Is there an easy way to do it with click that you know of? I would be open to using this if so.


#4

I can’t figure out what you mean by “return” here. Isn’t the checkbox’s selected state always reflected in the onOffState property of the associated member of the software array, so if you need it in component code, you can just get it from there?


#5

I am also experiencing this issue. Did you ever figure this out?