0

我在离子视图中有以下模式:

<ion-view id="doctors" cache-view="false" view-title="Directorio médico"  ng-controller="DoctorsDirController as doctorsCtrl">
  <ion-content>
              <!-- stuff inside here -->
  </ion-content>  
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            When this modal is open disable android back button
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
    <script id="result-details.html" type="text/ng-template">
      <ion-modal-view id="result-details-modal">
        <ion-content>

        </ion-content>
      </ion-modal-view>
    </script>
</ion-view>

config这是app.js中父视图(医生)的状态:

 .config(function ($stateProvider, $urlRouterProvider, $ionicConfigProvider) {

      .state('doctors', {
        url: '/doctors',
        templateUrl: "templates/doctors.html"
  })

所以在 app.js 里面run我试过:

  1. 禁用父视图的android后退按钮
  2. 但是对于所有其他视图,它们都充当正常的后退按钮。

代码:

.run(function ($ionicPlatform, $state) {$ionicPlatform.ready(function () {


    $ionicPlatform.registerBackButtonAction(function () {
      //if we are in doctors do nothing
      if ($state.current.url == "/doctors") {
        //do nothing

        //else if we are in dashboard exit app
      } else if ($state.current.name == "dashboard") {
        ionic.Platform.exitApp();

        //else normal back-button functionality
      } else {
        navigator.app.backHistory();
      }
    }, 100);

  })

问题是,当在“医生”内部调用模态时,它似乎是与父“医生”不同的状态,并且我的 android 后退按钮覆盖不再起作用。

4

1 回答 1

0

使用它来禁用模式中的android后退按钮:

$scope.modal.hardwareBackButtonClose = false;

于 2015-10-20T16:38:41.127 回答