I have a ngRepeat function to print some divs which the first one has the active class by default and on div click I want to set the div clicked active and the other ones with the inactive class and I have the next code but I don't know why is not working.
In my controller
$scope.activeSection = 0;
In my view
<div ng-repeat="div in divs" ng-class="activeSection == $index ? 'active' : 'inactive'" ng-click="activeSection = $index">
<p>Lorem......</p>
</div>
The problem here is when I do click, the div clicked becomes active but is not changing the last activated div to inactive and keeps the active class instead.
Hope you can help me.