我在离子视图中有以下模态:
<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>
这是app.js中config
内的父视图(医生)的状态:
.config(function ($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
.state('doctors', {
url: '/doctors',
templateUrl: "templates/doctors.html"
})
所以在app.js run
里面我试过了:
代码:
.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);
})
问题是当在“医生”内部调用模态时,它似乎与父母“医生”不同,我的安卓后退按钮覆盖不再起作用。
答案 0 :(得分:0)
使用它来禁用模式中的android后退按钮:
$scope.modal.hardwareBackButtonClose = false;