0
我可以在推送新頁面時隱藏標籤欄。但是當回到主屏幕時,如果我按設備後退按鈕,我不能再用腳本顯示標籤欄。在溫泉UI中顯示帶有JavaScript的標籤欄
請幫忙。以下是代碼:
module.run(function($rootScope){
$rootScope.incremental = 0;
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
// Handle the back button
if ($rootScope.home.getPages().length > 1) {
$rootScope.hide = 'false';
$rootScope.home.popPage();
e.preventDefault();
} else {
$rootScope.incremental++;
if($rootScope.incremental == 1){
ons.notification.confirm({
message: 'Are you sure you want to exit?',
title: 'Exit App?',
buttonLabels: ['Yes', 'No'],
cancelable: true,
callback: function(index) {
if(index == 0){
navigator.app.exitApp();
} else {
$rootScope.incremental = 0;
e.preventDefault();
}
}
});
e.preventDefault();
} else {
e.preventDefault();
}
}
}
});
<ons-tabbar animation="fade" hide-tabs="{{$root.hide}}">
<ons-tab active="true" page="index.html">
<div class="tab">
<ons-icon icon="ion-home" class="tab-icon"></ons-icon>
<div class="tab-label">Home</div>
</div>
</ons-tab>
<ons-tab page="about.html">
<div class="tab">
<ons-icon icon="ion-information-circled" class="tab-icon"></ons-icon>
<div class="tab-label">About App</div>
</div>
</ons-tab>
</ons-tabbar>
@Jabir_Charaniya將此標記爲答案! – pashute