Issue
I'm trying to use click event on ion-toggle and is not working.
Html:
<ion-item>
<ion-label class="labelToggle">Ativo:</ion-label>
<ion-toggle (click)="mudarStatusProcesso()" [(ngModel)]="ProcAtivo"></ion-toggle>
</ion-item>
The mudarStatusProcesso()
creates an AlertController with 'ok' and 'cancel' options, this action needs happen before ion-toggle updating. I believe that i should use other prop instead "(click)"
, can anyone help me?
Solution
You can use (ngModelChange),
<ion-item>
<ion-label class="labelToggle">Ativo:</ion-label>
<ion-toggle [(ngModel)]="ProcActivo" (ngModelChange)="mudarStatusProcesso()"></ion-toggle>
</ion-item>
In your .ts,
ProcActivo: boolean = false; // default value
mudarStatusProcesso(){
let alert = this.alertCtrl.create({
title: null,
message: "Confirm?",
buttons: [{
text: 'Cancel',
role: 'cancel',
handler: () => {
if(this.ProcActivo==false){
this.ProcActivo=true;
}else{
this.ProcActivo=false;
}
}
},
{
text: 'Okay',
handler: () => {
}
}
]
});
alert.present();
}
Answered By - Mystery
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.