This code is functioning properly with just one small request I have.
HTML:
<div class="item" ng-repeat="cell in [0,1,2]" data-ng-class="{active:index=='{{$index}}'}">
<button data-ng-click="activate('{{$index}}')">Activate Me</button>
</div>
Controller:
$scope.activate= function(index){
$scope.index=index;
};
The current functionality of the above code includes:
- The
active
class is applied to the parent div when its child is clicked. - The
active
class is removed if another item is clicked.
I would like to add one more feature:
If the same button is clicked again, I want to remove the already added active
class from the parent div
.