, ngRepeat , - , ngRepeat . , click items click ngClick, . f_click $scope , ngRepeat, .
f_click, ngRepeat, :
// Script
$scope.fun_click = (toggle) ->
return !toggle
// HTML
<span ng-click="f_click=fun_click(f_click)">{{j}}</span>
If you want to keep the state in $scope, you can use a dictionary to track the status of each $index:
// Script
$scope.form_status = {}
$scope.fun_click = (index) ->
$scope.form_status[index] = !$scope.form_status[index]
// HTML
<li ng-repeat="j in items" ng-class="{'red': form_status[$index]}">
<span ng-click="fun_click($index)">{{j}}</span>
</li>
The plunker is updated here: http://plnkr.co/edit/w6RLed?p=preview
source
share