我可以使用AngularJS在按钮上添加active
类吗?
例如:
<button class="first">first</button>
<button class="second">second</button>
<button class="third active">third</button>
<button class="fourth">fourth</button>
默认情况下,我想在third
上设置活动类,然后删除该类并将其添加到所选按钮。
答案 0 :(得分:0)
试试这个
<button class="first" ng-class="{'active':selcted == 'first'}">first</button>
<button class="second" ng-class="{'active':selcted == 'second'}">second</button>
<button class="third" ng-class="{'active':selcted == 'third'}">third</button>
<button class="fourth" ng-class="{'active':selcted == 'fourth'}">fourth</button>
JS
$scope.selcted = 'third';