循环li, 动态添加当前类
作者:互联网
html:
<div class="todayEnergyTab"> <ul> <li ng-repeat="item in todayEnergyChart" ng-click="getTodayEnergyChart($index,item)" ng-class="{'current': $index === isSelected}">{{item.name}}</li> </ul> </div>
js:
$scope.isSelected = 0 $scope.getTodayEnergyChart = function (index,item) { $scope.isSelected = index // console.log(index,item) // console.log($scope.isSelected) }
标签:index,console,log,item,li,isSelected,添加,scope,动态 来源: https://www.cnblogs.com/yongzhu/p/14550928.html