Xerc Xerc - 11 months ago 127
AngularJS Question

Set static uib-tab to active via method in angularJS

I am trying to use the uib-tabset in my project for the tabs. Everything is working good but I am trying to figure out how to set the active status of a tab via a method in my angularJS coding.

<uib-tabset active="active">
<uib-tab index="0">
<div>Some Con</div>
<uib-tab index="2">
<div>Some Con</div>
<uib-tab index="3">
<div>Some Con</div>

Is there some way to access the active attribute? I know I'm forgetting something but just cannot think of it at this moment. Any help is appreciated.

Answer Source

See this example: http://jsbin.com/xugavim/edit?html,js,output

You can simply set the active attribute passing a variable. Then modify the variable to change the active tab, like i do with this button (ng-click):

<button type="button" class="btn btn-default btn-sm" ng-click="active = 1">Select second tab</button>

You can see the same example, and more options, in the original documentation here: https://angular-ui.github.io/bootstrap/#/tabs