Tabs 爱奥尼亚:选项卡视图不';不显示后退按钮
我有一个简单的基于标签的Ionic应用程序。在应用程序进入实际选项卡模板之前,我已登录。在输入选项卡视图之前,用户可以使用导航栏上的后退按钮在视图之间导航,这是在创建新视图时自动生成的 但是,在进入选项卡后,这将不起作用。我希望选项卡有多个视图,框架应该管理导航栏,因为它有导航历史记录,并且知道用户来自哪里。我在互联网上读到过这方面的文章,但我找不到相关的例子 以下是选项卡的代码,一旦进入“邀请”视图,该选项卡应能够返回: tab-home.htmlTabs 爱奥尼亚:选项卡视图不';不显示后退按钮,tabs,ionic-framework,ionic-view,Tabs,Ionic Framework,Ionic View,我有一个简单的基于标签的Ionic应用程序。在应用程序进入实际选项卡模板之前,我已登录。在输入选项卡视图之前,用户可以使用导航栏上的后退按钮在视图之间导航,这是在创建新视图时自动生成的 但是,在进入选项卡后,这将不起作用。我希望选项卡有多个视图,框架应该管理导航栏,因为它有导航历史记录,并且知道用户来自哪里。我在互联网上读到过这方面的文章,但我找不到相关的例子 以下是选项卡的代码,一旦进入“邀请”视图,该选项卡应能够返回: tab-home.html <ion-view view-
<ion-view view-title="Angelsportverein Test e.V.">
<ion-header-bar class="bar-positive bar-subheader">
<h1 class="title">Mitglieder</h1>
<div class="buttons">
<!-- the register function navigates to the invite view -->
<button class="button icon icon-right" ng-click="invite()">
Einladen
</button>
</div>
</ion-header-bar>
<ion-content class="has-subheader">
<ion-list>
<ion-item ng-repeat="item in items">
Item {{ item.id }}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
app.js(请注意,注册、登录和忘记密码之间的导航功能应该是完美的)
tabs.html
<!--
Create tabs with an icon and label, using the tabs-positive style.
Each tab's child <ion-nav-view> directive will have its own
navigation history that also transitions its views in and out.
-->
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
<!-- Dashboard Tab -->
<ion-tab title="Home" icon-off="ion-home" icon-on="ion-home" href="#/tab/home">
<ion-nav-view name="tab-home"></ion-nav-view>
</ion-tab>
<!-- Kalender Tab -->
<ion-tab title="Kalender" icon-off="ion-calendar" icon-on="ion-calendar" href="#/tab/kalender">
<ion-nav-view name="tab-kalender"></ion-nav-view>
</ion-tab>
<!-- Fangbuch Tab -->
<ion-tab title="Fangbuch" icon-off="ion-folder" icon-on="ion-folder" href="#/tab/fangbuch">
<ion-nav-view name="tab-fangbuch"></ion-nav-view>
</ion-tab>
</ion-tabs>
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
</head>
<body ng-app="starter">
<!--
The nav bar that will be updated as we navigate between views.
-->
<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<!--
The views will be rendered in the <ion-nav-view> directive below
Templates are in the /templates folder (but you could also
have templates inline in this html file if you'd like).
-->
<ion-nav-view></ion-nav-view>
</body>
</html>
它无法工作,因为您的
邀请状态的状态配置不正确。您已将invite
指定为tab
状态的同级,但它应该是tab.home
的子级,以便ion导航栏
指令自动生成后退按钮并处理历史记录。此外,还需要在命名选项卡选项卡home
中呈现邀请
视图。按以下方式更改您的状态配置,您的预期行为应正常工作:
.state('tab.invite', {
url: '/invite',
views: {
'tab-home': {
templateUrl: 'templates/invite.html',
controller: 'InviteCtrl'
}
}
})
作品现在我了解了整个系统的工作原理,非常感谢!还有一件事:在导航栏中,箭头图标旁边总是有上一个视图的名称。现在它只显示“Back”,我能改变它吗?你想删除这个名字吗?在这种情况下,您可以将以下命令用于app.config
方法:$ionicConfigProvider.backButton.previousTitleText(false)$ionicConfigProvider.backButton.text(“”)代码>另外,请接受答案,如果你的问题得到解决,请(或)投票:)那么这应该有效。将方法调用$ionicConfigProvider.backButton.previousTitleText(true)
添加到app.config
不,它已经工作了,我的错误是上一个视图的名称太长。我将把它移到导航栏下面的一个简单文本中,并将其替换为“Home”。非常感谢你!!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
</head>
<body ng-app="starter">
<!--
The nav bar that will be updated as we navigate between views.
-->
<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<!--
The views will be rendered in the <ion-nav-view> directive below
Templates are in the /templates folder (but you could also
have templates inline in this html file if you'd like).
-->
<ion-nav-view></ion-nav-view>
</body>
</html>
.state('tab.invite', {
url: '/invite',
views: {
'tab-home': {
templateUrl: 'templates/invite.html',
controller: 'InviteCtrl'
}
}
})