0
我試圖覆蓋硬件後退按鈕功能。 因此,下面的代碼一切正常。硬件後退按鈕不起作用?
但是,在我的應用程序中有兩個$ ionicModal。當$ ionicModal打開和關閉。硬件後退按鈕停止工作,應用程序無法關閉後退按鈕? 甚至沒有$ ionicPlatform.registerBackButtonAction函數被調用。
$state.$current.name == "";
var backbutton=0;
$ionicPlatform.registerBackButtonAction(function (event) {
if (($state.$current.name == "app.intro") ||
($state.$current.name == "app.main.home") ||
($state.$current.name == "app.account") ||
($state.$current.name == "app.myBusiness")||
($state.$current.name == "app.support")||
($state.$current.name == "app.noConnection")) {
if(backbutton==0){
backbutton++;
window.plugins.toast.showLongBottom('Press again to exit');
$timeout(function(){backbutton=0;},3000);
}else{
navigator.app.exitApp();
}
console.log("one");
}else if($state.$current.name == "app.welcome.takeControl") {
console.log("two");
$state.go("app.main.home");
}else{
console.log("three");
navigator.app.backHistory();
}
}, 100);
謝謝。
很好的解釋..!它做..!我是開相同的離子態兩次..!閉只一次..! –