Ionic 2 beta9 - Toggle - ionChange


#1

Hello all!

I have a problem with the toggle component…

When I click in the component, the ionChange event fire two times…

<ion-toggle [(ngModel)]="notification" (ionChange)="toggleNotification()"></ion-toggle>
toggleNotification() {
         console.log('test');
}

Cordova CLI: 6.1.1 Ionic Framework Version: 2.0.0-beta.9-201606212210 Ionic CLI Version: 2.0.0-beta.30 Ionic App Lib Version: 2.0.0-beta.16

any sugestion?


Ionic 2 toggle component binding and events
#2

Hmm, I just tested this out with beta9 and also the nightly builds and haven’t been able to replicate

import {Component} from "@angular/core";
@Component({
  template: `
    <ion-content>
      <ion-list>
        <ion-item>
          <ion-label>Pepperoni</ion-label>
          <ion-toggle [(ngModel)]="pepperoni" (ionChange)="logEvent($event)"></ion-toggle>
        </ion-item>
      </ion-list>
    </ion-content>
  `
})
export class HomePage {
  logEvent(e) {
    console.log(e)
  }
}

Logs out the event once per click.