如何使用 angularjs 切换子元素 class

how to toggle the child element class using angularjs

点击锚点如何切换子跨度元素类?

我的锚点已经有了点击功能:点击如何切换"glyphicon-chevron-down"到"glyphicon-chevron-up"?

    <a ng-click="toggleList()">
     View More <span class="glyphicon glyphicon-chevron-down"></span>
    </a>

你可以

标记

<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';
}