我想在部分视图tab-suggestion
中创建一个按钮,该按钮会指向另一个名为tab-profile
的视图。问题是href="#/tab/profile"
没有做任何事情。选项卡导航中的链接工作得很好,但离子视图tab-suggestion
中的按钮却没有。
如何让按钮直接指向profile
?这是我的代码:
//app.js
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.state('tab.suggestion', {
url: '/suggestion',
views: {
'tab-suggestion': {
templateUrl: 'templates/tab-suggestion.html',
controller: 'SuggestionCtrl'
}
}
})
.state('tab.profile', {
url: '/profile',
views: {
'tab-profile': {
templateUrl: 'templates/tab-profile.html',
controller: 'ProfileCtrl'
}
}
})
//index.html
<ion-nav-view></ion-nav-view>
//tab-suggestion
<a class="button" ng-if="randomConnection === 'maker'" href="#/tab/profile">Contact</a>
修改 //tabs.html
<!-- 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>
<ion-tab title="Suggestie" icon-off="ion-android-bulb" icon-on="ion-android-bulb" href="#/tab/suggestion">
<ion-nav-view name="tab-suggestion"></ion-nav-view>
</ion-tab>
<ion-tab title="Feed" icon-off="ion-arrow-graph-up-right" icon-on="ion-arrow-graph-up-right" href="#/tab/feed">
<ion-nav-view name="tab-feed"></ion-nav-view>
</ion-tab>
</ion-tabs>
答案 0 :(得分:0)
当按下标签时,它是按设计选择的(当你明显触摸它时,Ionic可以确定现在必须选择此标签)。如果您尝试从当前视图内的按钮路由到另一个选项卡,我建议您编写一个包含以下内容的函数:
function() {
$state.go('yourstate');
$ionicTabsDelegate.select(0); //index of the tab to select
}
$ ionicTabsDelegate允许您以编程方式选择所选的选项卡。
如果您需要进一步说明,请告诉我,这是短版本,因为我正在打电话。 :)