2013-04-03 52 views

回答

4

ng-model添加一個初始值,然後用ng-class設置動態類

Plnkr

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

查看

<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> 

控制器

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

app.controller("TabsCtrl", function($scope) { 
    $scope.currentTab = 1; 
});