I have a Toggle switch. I want not to check or uncheck the toggle at first which is why I need to use preventDefault.
I have used ionChange() instead of click() event handler. But with ionChange handler, the cancelable or defaultPrevented property does not exists. So, it raises error that preventDefault() is not a function. However, with simple click handler, it does not raise any error but does not work either. I have also tried with stopPropagation().
Here is the code.
HTML:
<ion-item>
<ion-toggle [(ngModel)]="appliance.state" (ionChange)="applianceChange($event)"></ion-toggle>
</ion-item>
TS:
import { Component, EventEmitter } from '@angular/core';
@Component({
selector: 'appliances',
templateUrl: 'appliances.html'
})
export class ApplianceModule {
constructor(){}
applianceChange(event: Event){
event.preventDefault();
}
}