1

I have used tab component in Angular Bootstrap UI and ui-router for routing in my Angularjs app.

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).

1
  • Use $stateParams for that to get passed parameter. And define the parameter url: '/entity/list?param1&param2 in a route if needed. Commented Sep 6, 2016 at 9:47

1 Answer 1

0

I Solved my problem!

If each tab has exclusive route, we can use angular ui router sticky to handle this.

use bootstrap

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

h1 users list page

newuser.pug

h1 new user page

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.