我已經爲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然後我必須再次寫所有這些代碼註冊。我如何覆蓋特定頁面的後退按鈕只有他的控制器
添加你的示例代碼 –