我已经为app.run()
中的所有状态编写$ionicPlatform.registerBackButtonAction
。因此,当应用程序初始化时,它为所有页面注册后退按钮。现在,我想更改特定页面的硬件后退按钮功能该页面的控制器。如何不注册所有其他页面。如何禁用Ionic中特定页面的硬件按钮
$ionicPlatform.registerBackButtonAction(function() {
if ($state.current.name == 'app.homepage' || $state.current.name == 'app.loginUser') {
navigator.app.exitApp();
} else if ($state.current.name == "app.contacts" || $state.current.name == 'app.carDocuments' || $state.current.name == 'app.tracking' || $state.current.name == 'app.logBook'|| $state.current.name == 'app.geofence' || $state.current.name == 'app.walktocar' || $state.current.name == 'app.dashboard' || $state.current.name == 'app.geofenceTest' || $state.current.name == 'app.settings' || $state.current.name == 'app.about' || $state.current.name == 'app.tripDetail' || $state.current.name == 'app.newTripDetail'|| $state.current.name == 'app.followMeTrack' || $state.current.name == 'app.followMe' || $state.current.name == 'app.maintainance' || $state.current.name == 'app.faultHistory' || $state.current.name == 'app.routeType'|| $state.current.name == 'app.poi') {
if ($rootScope.isDeletePage == "true") {
$rootScope.$broadcast('callOriginalView');
$rootScope.isDeletePage = "false";
} else {
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('app.homepage');
}
} else {
$ionicHistory.goBack();
}
}, 100);
因此,如果我再次写$ ionicPlatform.registerBackButtonAction然后我必须再次写所有这些代码注册。我如何覆盖特定页面的后退按钮只有他的控制器
添加你的示例代码 –