禁用 android 模态 <ion-modal-view> 的后退按钮
disable android back button for modal <ion-modal-view>
我在离子视图中有以下模态:
<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
我试过:
- 禁用 android 父视图的后退按钮
- 但对于所有其他视图,充当正常的后退按钮。
代码:
.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);
})
问题是,当在 "doctors" 中调用模态时,它似乎与父 "doctors" 处于不同的状态,并且我的 android 后退按钮覆盖不再起作用。
使用它来禁用模式中的 android 后退按钮:
$scope.modal.hardwareBackButtonClose = false;
我在离子视图中有以下模态:
<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
我试过:
- 禁用 android 父视图的后退按钮
- 但对于所有其他视图,充当正常的后退按钮。
代码:
.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);
})
问题是,当在 "doctors" 中调用模态时,它似乎与父 "doctors" 处于不同的状态,并且我的 android 后退按钮覆盖不再起作用。
使用它来禁用模式中的 android 后退按钮:
$scope.modal.hardwareBackButtonClose = false;