I am using ng-repeat to populate a list of items.
<ul>
<li ng-repeat="item in items" ng-class="setClass" ng-click="assignClass()">{{item.name}}</li>
</ul>
In my controller, I have the following code:
$scope.assignClass = function(){
$scope.setClass = "sampleClass";
}
The issue I'm facing is that when I click on any item, all items get the 'sampleClass' added.
My desired scenario is that when I click on the first item, only that item should have the 'sampleClass'. When I click on the second item, both the first and second items should have the 'sampleClass'.
How can I achieve this behavior?