Whenever I click on an item from my list displayed using ngrepeat
, it generates another list specific to the selected element. My goal is to change the background color of the clicked element to indicate it has been selected. However, the problem arises when multiple items appear selected at once even after selecting a new one. Below is the code snippet:
<div class="breakdownRow pointer" ng-class="{bSelection: selection}" ng-click="selection=true" ng-repeat="m in masterList">
<span class="areaTag">{{m.area}}</span>
<span class="storeNumTag" ng-repeat="v in m.valueList track by $index">{{v.toLocaleString()}} </span>
</div>
The first click event works fine and changes the background color using the CSS class bSelection. However, the issue persists as previously selected elements remain highlighted even after selecting a new one.
Question: Is there a way to remove the highlighting from a previously selected element when a new element is chosen so that only one remains highlighted at any given time?