单击锚点如何切换子span元素类?
我的锚点上已经有一个点击功能:点击如何切换" glyphicon-chevron-down" to" glyphicon-chevron-up" ?
<a ng-click="toggleList()">
View More <span class="glyphicon glyphicon-chevron-down"></span>
</a>
答案 0 :(得分:1)
你可以
<强>标记强>
<a ng-click="toggleList()">
View More <span class="glyphicon" ng-class="getClass()"></span>
</a>
<强>代码强>
$scope.toggleList = function(){
//other logic here
$scope.isDown = !$scope.isDown;
}
$scope.getClass = function(){
return $scope.isDown ? 'glyphicon-chevron-down': 'glyphicon-chevron-up';
}