I'm trying to use ionic-alert with Angular deactivate keeping the behaviors of the "confirm" function.
canDeactivate(component: UserFormComponent) {
if (component.userFormView.userForm.dirty) {
this.confirmDeactivate();
}
return true;
}
private async confirmDeactivate() {
const alert = await this.alertController.create({
header: 'Confirm!',
message: 'Message <strong>text</strong>!!!',
buttons: [{
text: 'Cancel',
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => {
console.log('Confirm Cancel: blah');
}
}, {
text: 'Okay',
handler: () => {
console.log('Confirm Okay');
}
}]
});
await alert.present();
}
With this code, when I click to change the page, the page changed then the confirm dialog appear.
When I use confirm() instead of this function, that works great, the page wait for the answer.
How can I do to get the same behaviors than the Window confirm function ?