4

I try to disable back button on android device with "keyboard: false" but it not work.

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

How to disable it. Thank you.

3 Answers3

17

ionicModal provides hardwareBackButtonClose option to set false for this behaviour.

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

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

Mudasser Ajaz
  • 6,197
  • 1
  • 26
  • 29
0

Another option could be: isShown() method as mentioned in the docs http://ionicframework.com/docs/api/controller/ionicModal/

You can go for something like this
if(!$scope.modal.isShown()){
navigator.app.exitApp();
} else{
//do nothing...
}

Amir Aslam
  • 383
  • 4
  • 9
-1

Check this thread: Disable hardware back button in Ionic application?

This should do it:

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

But I would advice against this unless you really need to. Breaking the expected model of operation very slightly hurts the entire platform.

Community
  • 1
  • 1
SilentStorm
  • 172
  • 1
  • 1
  • 12