gpt4 book ai didi

javascript - ionic 框架 $state.go ('app.home' );在我想去的页面上添加后退按钮(如何删除它)?

转载 作者:IT王子 更新时间:2023-10-29 02:59:54 32 4
gpt4 key购买 nike

我有带侧边栏菜单的应用程序。我在第二页上,我正在调用 Controller 函数,它使用以下命令将我重定向到第一页:

$state.go('app.home');

问题是这个页面现在显示后退按钮下一个侧边栏菜单图标,见下图:

enter image description here

有人能告诉我如何拒绝将后退按钮添加到已分配侧边栏菜单的页面吗?

感谢您的帮助。

app.js 与路由器配置如下:

angular.module('Test', ['ionic', 'config', 'Test', 'LocalStorageModule'])

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})

.config(function($stateProvider, $urlRouterProvider, localStorageServiceProvider) {
localStorageServiceProvider
.setPrefix('max_relax');
$stateProvider

.state('app', {
url: '/app',
abstract: true,
templateUrl: 'templates/menu.html',
controller: 'AppCtrl'
})

.state('app.home', {
url: '/home',
views: {
'menuContent' :{
templateUrl: 'templates/home.html',
controller: 'HomeCtrl'
}
}
})

.state('app.saved', {
url: '/saved',
views: {
'menuContent' :{
templateUrl: 'templates/saved.html',
controller: 'SavedCtrl'
}
}
})
.state('app.settings', {
url: '/settings',
views: {
'menuContent' :{
templateUrl: 'templates/settings.html',
controller: 'SettingsCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/home');
});

编辑:

添加菜单模板:

<ion-side-menus>

<ion-pane ion-side-menu-content>
<ion-nav-bar class="bar-stable">
<ion-nav-back-button class="button-clear"><i class="icon ion-ios7-arrow-back"></i> Back</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
</ion-pane>

<ion-side-menu side="left">
<header class="bar bar-header bar-stable">
<h1 class="title">Menu</h1>
</header>
<ion-content class="has-header">
<ion-list>
<ion-item nav-clear menu-close href="#/app/home">
Home
</ion-item>
<ion-item nav-clear menu-close href="#/app/saved">
Saved
</ion-item>
<ion-item nav-clear menu-close href="#/app/settings">
Settings
</ion-item>

</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>

最佳答案

使用$ionicHistory在您的 Controller 中调用 $state.go('app.home')

.controller('HomeCtrl', function($scope,...,$ionicHistory) {
...
$ionicHistory.nextViewOptions({
disableBack: true
});

$state.go('app.home');
});

关于javascript - ionic 框架 $state.go ('app.home' );在我想去的页面上添加后退按钮(如何删除它)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27930702/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com