Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the initial static tab in angular bootstrap

I don't seem to be able to set the inital tab in an angular bootstrap tabset. It always sets the left most tab to active.

Given the html:

<tabset>
    <tab heading="Static 1" active="data.static1">Static content</tab>
    <tab heading="Static 2" active="data.static2">Static content</tab>
</tabset>

and js:

angular.module('plunker', ['ui.bootstrap']);
var TabsDemoCtrl = function ($scope) {
  $scope.data = {static1: false, static2: true}
};

See the Plunker

Update 6 Aug 2013: Now fixed upstream see the github issue.

like image 246
Cam Avatar asked Jul 17 '13 09:07

Cam


1 Answers

It seems like (static) tabs overwrite whatever is passed to active when the directive is run. I assume it's a bug. Quick and dirty, you can use a timeout with 0 seconds delay to set the active state. At least in the plunkr, this does not cause any flicker. In your controller:

$scope.data = {};
$timeout(function() {
  $scope.data.static2 = true;  
}, 0)

http://plnkr.co/edit/3KbdKh?p=preview

like image 170
Narretz Avatar answered Sep 27 '22 16:09

Narretz