Reputation: 2536
When Toggle button is "on" see below the function buttonOn()
is called,
I want to call buttonOff()
when toggling it "off" as below
.html
<ion-toggle (ionChange)="buttonOn()"></ion-toggle>
.ts
buttonOn() {
// this function is called;
}
buttonOff() {
// how to call this function when toggle button gets off?
}
Upvotes: 0
Views: 1693
Reputation: 517
Let's use ngModel
to bind your toggle's status, then call the function depends on the status
.html
<ion-toggle [(ngModel)]="status" (ionChange)="onChange()"></ion-toggle>
.ts
status=true;
onChange(){
if(this.status){
this.buttonOn();
}
else{
this.buttonOff()
}
}
buttonOn() {
// this function is called;
}
buttonOff() {
// how to call this function when toggle button gets off?
}
Upvotes: 5