How to disable the back button when using ion modal on Android?

I am trying to disable the back button on an Android device with a "keyboard: false", but it does not work.

$ionicModal.fromTemplateUrl('templates/login.html', {
  scope: $scope,
  keyboard: false
})

How to disable it. Thanks.

+4
source share
3 answers

ionicModal provides option hardwareBackButtonClosefor installation falsefor this behavior.

  $ionicModal.fromTemplateUrl('templates/login.html', {
      scope: $scope,
      hardwareBackButtonClose: false
  })

See related documentation: http://ionicframework.com/docs/api/controller/ionicModal/

+16
source

Another option might be: isShown (), as documented in http://ionicframework.com/docs/api/controller/ionicModal/

-
   (! $scope.modal.isShown()) {
      navigator.app.exitApp();
  } else {
    // ...
 }

0

Check this topic: Disable hardware return button in Ionic app?

This should do it:

$ionicPlatform.registerBackButtonAction(function () {
  if (condition) {
    navigator.app.exitApp();
  } else {
    handle back action!
  }
}, 100);

But I would advise against this if you really don't need to. Violation of the expected model of work will damage the whole platform very slightly.

-1
source

Source: https://habr.com/ru/post/1606601/


All Articles