Clicking on 'OK' automatically dismisses the alert. I want to add some logic inside 'OK' click handler and then decide if I want to dismiss the alert or not.
let inputsAlert = this.alertCtrl.create({
...
buttons: [
{
text: 'OK',
handler: inputsData => {
// Some logic here
if (canDismiss) {
this.inputsAlert.dismiss();
} else {
// Do nothing
}
}
}
]
})
In the array of buttons, each button includes properties for its text, and optionally a handler. If a handler returns false then the alert will not automatically be dismissed when the button is clicked.
From https://ionicframework.com/docs/api/alert#buttons
Simply return false
if you do not want the alert to be dismissed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With