Aanchal Aanchal - 3 months ago 8
AngularJS Question

Button inside one static tab to show second tab is not working when using angular ui bootstrap

I want that on clicking a button inside one static tab would take me to another tab. I am trying using angular ui bootstrap but it is not working. I am using below code but it is not working-

<uib-tab index="0" heading="Static title">Static content
<button class="btn btn-default btn-sm" ng-click="tabs[2].active = true">Select third tab</button>

</uib-tab>


I have created a plunker here-
https://plnkr.co/edit/dTdsbeWbWiIqvmjh2IY8?p=preview

Can anyone tell me how can I achieve this?

Answer

I tried this and it worked.

<button class="btn btn-default btn-sm" ng-click="secondTab()">Select second tab</button>

In controller:

$scope.secondTab = function(){
  $scope.active = 2;
}

https://plnkr.co/edit/wZ8yIkjvoLO82wvG5UBc?p=preview

Comments