3 つのボタンからカルスを追加/削除しようとしていますが、何らかの理由で複数のクリックが必要な場合があります
<a class="button small">
<i class="icon-circle-arrow-up" ng-click="select('slide')" ng-class="{active: 'slide' == selected}"></i>
</a>
<a class="button small">
<i class="icon-resize-horizontal" ng-click="select('wave')" ng-class="{active: 'wave' == selected}"></i>
</a>
<a class="button small">
<i class="icon-repeat" ng-click="select('role')" ng-class="{active: 'role' == selected}"></i>
</a>
JavaScript:
myApp.controller("TodoCtrl", function($scope, $http) {
$scope.slide = "one";
$scope.animate = "slide";
$scope.selected = "slide";
return $scope.select = function(item) {
$scope.selected = item;
return $scope.animate = item;
};
});
プランカー: