I am writing an ionic 2 app. I want to close the popover on back button click when the popover is open or open an alert control on backbutton click when popover is not opened. below is my code. But when the back button is clicked…the popover does not close.
backButtonAction() {
if(this.popover.present())
{
this.popover.dismiss();
}
else if (this.popover.onDidDismiss()) {
let alert = this.alertCtrl.create({
title: 'Exit App',
message: 'Do you want to close this app?',
buttons: [
{
text: 'Yes',
handler: () => {
console.log('yes clicked');
this.platform.exitApp();
this.viewCtrl.dismiss();
this.popover.dismiss();
}
},
{
text: 'No',
role: 'cancel',
handler: () => {
console.log('no clicked');
this.viewCtrl.dismiss();
this.popover.dismiss();
}
}
]
});
alert.present();
}
*/
}