简体   繁体   English

如何在更改路径后激活Angular Bootstrap UI中的选项卡

[英]How to active tab in Angular Bootstrap UI after change route

I have used tab component in Angular Bootstrap UI and ui-router for routing in my Angularjs app. 我在Angular Bootstrap UI中使用了tab组件 ,在我的Angularjs应用程序中使用了ui-router进行路由。

Now I want to active one of tabs, after change route. 现在我想在更改路线后激活其中一个标签。 In fact I have a search route and I want to change tabs due to the search options (that users can select where they want to search). 事实上,我有一个搜索路线,我想更改标签,因为搜索选项 (用户可以选择他们想要搜索的位置)。

I Solved my problem! 我解决了我的问题!

If each tab has exclusive route, we can use angular ui router sticky to handle this. 如果每个选项卡都有独占路由,我们可以使用angular ui router sticky来处理这个问题。

use bootstrap 使用bootstrap

users.pug users.pug

ul.nav.nav-tabs

    li.nav-item(ui-sref-active-eq='active')
       a.nav-link(ui-sref="users") users list

    li.nav-item(ui-sref-active-eq='active')
       a.nav-link(ui-sref="users.newUser") newUser

.tab-content(ui-view="usersTab")

usersList.pug usersList.pug

h1 users list page

newuser.pug newuser.pug

h1 new user page

route.js route.js

.state('users', {
    url: '/users',
    templateUrl: 'users.html',
    controller: 'usersCtrl'
})
.state('usersList', {
    url: '/usersList',
    sticky: true,
    views: {
       "usersTab": {
           templateUrl: 'usersList.html',
           controller: 'usersListCtrl'
       }
    }
})
.state('newUser', {
    url: '/newUser',
    sticky: true,
    views: {
       "usersTab": {
           templateUrl: 'newUser.html',
           controller: 'newUserCtrl'    
       }
    }

})

And to active each tab can use: ui-sref-active-eq='active' and .active class change active tab style 并激活每个选项卡可以使用: ui-sref-active-eq='active'.active类更改活动选项卡样式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Angular Bootstrap UI中从头开始激活选项卡? - How to make a tab active from the beginning in Angular Bootstrap UI? Angular UI选项卡 - 以编程方式更改活动选项卡 - Angular UI tabs - change active tab programmatically angular ui bootstrap选项卡组件:未单击选项卡处于活动状态时如何获取选项卡内容 - angular ui bootstrap tabs component: how to get the content of a tab when the tab is active not clicked 如何将活动类应用于Bootstrap Tab UI - How to apply active class to bootstrap Tab ui Angular UI Bootstrap选项卡在路由更改时打开 - Angular UI Bootstrap Tabs open on route change Angular 和 bootstrap UI 选项卡都激活以防止默认 - Both Angular & bootstrap UI tab become active in prevent default 使用Angular UI Bootstrap在动态创建的选项卡上设置活动选项卡 - Setting active tab on dynamically created tabs with Angular UI Bootstrap Angular + bootstrap-ui,检查当前选项卡是否已激活 - Angular + bootstrap-ui, check if current tab is already active 如何在角度引导ui的活动导航选项卡中聚焦第一输入字段? - How to focus fist input field in the active navigation tab in angular bootstrap ui? 根据Angular中的路由更改添加Bootstrap活动类 - add Bootstrap active class based on route change in Angular
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM