3 つの方法があります:
1. $scope を介したバインド (推奨されません)
2. キー/値のキーと値のペアを介したバインド
function ctrl($scope) { $scope.className = "selected"; }
<div class="{{className}}"></div>
function ctrl($scope) { $scope.isSelected = true; }
<div ng-class="{true:'selected',false:'unselected'}[isSelected]"></div>
function ctrl($scope) { $scope.isA = true; $scope.isB = false; $scope.isC = false; }
<div ng-class="{'A':isA,'B':isB,'C':isC}"></div>
<ion-list> <ion-item ng-repeat="project in projects" ng-click="selectProject(project, $index)" ng-class="{active: activeProject == project}"> {{project.title}} </ion-item> </ion-list>