我在离子视图中有以下模式:
<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
我试过:
- 禁用父视图的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);
})
问题是,当在“医生”内部调用模态时,它似乎是与父“医生”不同的状态,并且我的 android 后退按钮覆盖不再起作用。