senthil senthil - 4 months ago 56
jQuery Question

UIB tabs - set second tabs is active

Its is uib bootstrap plugin. Default active the first tab.
I need to set the second tab is default active. Kindly help me as soon as possible.

<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.4.js"></script>
<script type="text/javascript">
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TabsDemoCtrl', function($scope, $window) {

});
</script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="TabsDemoCtrl">
<uib-tabset active="active">
<uib-tab index="0" heading="Static title">Static First</uib-tab>
<uib-tab index="1" heading="Static title1">Static Second</uib-tab>
<uib-tab index="2" heading="Static title2" active="true">Static Third</uib-tab>
</uib-tabset>
</div>
</body>
</html>

Answer

Something like:

    <div ng-controller="TabsDemoCtrl" ng-init="indextab = 1">
        <uib-tabset active="indextab">
            <uib-tab index="0" heading="Static title">Static First</uib-tab>
            <uib-tab index="1" heading="Static title1">Static Second</uib-tab>
            <uib-tab index="2" heading="Static title2" active="true">Static Third</uib-tab>
        </uib-tabset>
    </div>

does what you need.

Updated plunker