On my HTML page, I have 2 lists that I want to modify so that when an option is clicked, it adds a class altering the background-color of the li element to red. If the same option is clicked again, it removes the class and reverts back to white:
This is the current structure of the lists in my HTML template:
List A
<ul>
<li>Something 1</li>
<li>Something 2</li>
</ul>
List B
<ul>
<li>Otherthing A</li>
<li>Otherthing B</li>
<li>Otherthing C</li>
</ul>
Currently, I am using individual expressions for each li element along with separate $scope variables that track true or false values. For example: $scope.otherthingaclicked = true, $scope.otherthingbclicked = true, $scope.otherthingcclicked=false, etc.
<li ng-class="expression">Otherthing A</li>
I believe there must be a more efficient way to handle this. What is a better approach to make this functionality smarter?