1
votes

I’m using Ionic 4 with Angular 8 I want to “Disable” modal dismiss when i press android hardware “back” button.

this.platform.backButton.subscribe(() => {
      console.log("Button Pressed");
    });

I can trace the event but i can’t prevent ionic to dismiss modal.

2

2 Answers

1
votes

just add ModalOption backdropDismiss: false

0
votes
this.platform.backButton.subscribe(async () => {
  console.log("Button Pressed");
  if (this.modalCtrl.getTop()) {
    const modal = await this.modalCtrl.getTop();
    if (modal) {
      console.log('ModalCtrl Top');
      return;
    }
  }
});