Ion-toggle (ionChange) triggered

After using ngModelChange instead of ionChange, the following worked

<ion-toggle slot="end" [checked]="push_notifications" (ngModelChange)="push($event)" [(ngModel)]="push_notifications"></ion-toggle>
import { ChangeDetectorRef, ... } from '@angular/core';

constructor(private cdref: ChangeDetectorRef, ...) 

ngAfterContentChecked() {
    this.cdref.detectChanges();
}

Used this as reference - angular - ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'undefined' - Stack Overflow

It works for checkboxes as well

<ion-select multiple="true" interface="action-sheet" [(ngModel)]="service" [value]="list" (ngModelChange)="selected(service)" >
    <ion-select-option required *ngFor="let service of services" value="{{service.id}}">
        {{service.title}}
    </ion-select-option>
</ion-select>

This is working for me. Just remove ngModel

 <ion-toggle [checked]="available"
  (ionChange)="availabilityChanged($event, available)"></ion-toggle>
1 Like