ionic-framework: bug: Toggle call ionChange on view init
Type: <span ionic-type>bug</span>
Ionic Version: <span ionic-version>2.x</span>
Platform: <span ionic-platform>all</span>
<span ionic-description>This is my toggle: <ion-toggle [(ngModel)]=“workMode” (ionChange)=“workModeChanged()”></ion-toggle>
if this.workMode == true so workModeChanged callback will called on page init, even without click on the toggle. that is the bug.
if this.workMode == false there is no bug.
Thanks</span>
<span is-issue-template></span>
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (6 by maintainers)
Commits related to this issue
- fix(toggle): initialize at ngAfterContentInit — committed to ionic-team/ionic-framework by manucorporat 7 years ago
- fix(base-input): first ngModel update is not dispatched — committed to ionic-team/ionic-framework by manucorporat 7 years ago
I can reproduce the issue again on Ionic 3. I have fetched the value from backend and set the field in both constructor and ngOnInit. Both ways cause event to fire.
Ionic version:
“ionic-angular”: “3.0.1”
Constructor code:
}
HTML:
<ion-item><ion-label>Disable account</ion-label><ion-toggle [(ngModel)]="disableAccount" (ionChange)="toggleDisableAccount()" checked="false"></ion-toggle></ion-item>