1

I have an angular tabbable here. How can I set default tab? + add a class to specific tab?

http://plnkr.co/edit/FPMf8i

e.g. I want the tab 2 to be slected by default. Then tab 1 have a specific class.

I tried

 element.children[1].addClass('test');
 element[0].children[0].addClass('test');
 element[0].addClass('test');

but keep getting an error

Can't use jquery has to be library already there.

1 Answer 1

4

Add an initial value for your ng-model, then use ng-class to set dynamic classes

Plnkr

http://plnkr.co/edit/udxAT0?p=preview

View

<div ng-controller="TabsCtrl">
  <div class="tabbable" ng-model="currentTab">
    <div class="tab-pane" ng-class="{'special-class': currentTab == 1}" title="1" value="1">
      Content 1
    </div>
    <div class="tab-pane" title="2" value="2">
      Content 2
    </div>
  </div>
</div>

Controller

var app = angular.module('plunker', ['bootstrap']);

app.controller("TabsCtrl", function($scope) {
  $scope.currentTab = 1;
});
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.