ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

ion-toggle unnecessarily triggers `change` event when default value is true

Open cubicleWar opened this issue 10 years ago • 21 comments

This is reposting of issue #6144 from beta 4 it appears to have made its way back into beta 11

Short description of the problem:

ion-toggle unnecessarily triggers change event when the default value is true

What behavior are you expecting?

The change event should not fire until the user presses the toggle

Steps to reproduce:

  1. Create an ion-toggle with ngModel bound to a variable with a default value of true
  2. Observe change event firing without any user input

toggle: boolean = true;

<ion-toggle [(ngModel)]="toggle" (ionChange)="onUpdateToggle()">

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

  • This appears to be the same issue as #6144
  • This only fires when the default value is true.

Which Ionic Version? 1.x or 2.x

2.0.0-beta.11

Plunker that shows an example of your issue

Note this is the plunk of the original issue there seems to be no plunk template for beta 11 and this is not an issue in beta 10. I have attached a sample project to demonstrate the problem in beta 11

http://plnkr.co/edit/f2NSVLP1DETbkyFmpSN8?p=preview

Run ionic info from terminal/cmd prompt: (paste output below)

Cordova CLI: 6.3.1 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.11 Ionic CLI Version: 2.0.0 Ionic App Lib Version: 2.0.0 ios-deploy version: 1.8.6 ios-sim version: 5.0.8 OS: Mac OS X El Capitan Node Version: v4.4.5 Xcode version: Xcode 7.3 Build version 7D175

cubicleWar avatar Aug 20 '16 22:08 cubicleWar

Issue moved to: https://github.com/ionic-team/ionic-v3/issues/127

ionitron-bot[bot] avatar Nov 28 '18 21:11 ionitron-bot[bot]