I'm using solution 2 posted in this S.O. question to toggle a class with ng-click. In my case, I want to display a Font Awesome closed folder icon when a list element is not clicked and display a open folder icon when the list element is clicked. This takes place in a nested menu sequence. It works fine when the list element is clicked to open its submenu and clicked again to close to the submenu: the folder icon changes from closed to open and vice-versa:
However, if the other list elements are clicked, their icon changes as expected. The problem is the original folder open icon still displays for the menu items that have closed. I would like to toggle the class on all the other list elements that have open folders to the closed folder class again and I'm not sure how to do that. How can I toggle the classes for all my other list elements displaying the open folder class to closed folder class when one of the others is clicked? See the screenshot below for what I mean about the other folders showing the open class after I've clicked the first two and then the third:
This is the code I'm using the toggle the class:
<a ng-click="folderOpen = !folderOpen" href="#">
<i ng-class="folderOpen ? 'fa fa-folder-open-o' : 'fa fa-folder-o'"></i>
<{ item.pretty_name }>
</a>
I'd like to toggle all the classes that have 'fa fa-folder-open-o' to 'fa fa-folder-o' when one of the other anchor elements is clicked. How do I do that?
Edit: per request I have added the surrounding code that creates the list elements, that's pretty much all the code I have to generate the menus (should I include the html head, body & aside elements too?! :) There's nothing special in my controller code either:
<li ng-repeat="item in data.dirs" metis="">
<a ng-click="folderOpen = !folderOpen" href="#">
<i ng-class="folderOpen ? 'fa fa-folder-open-o' : 'fa fa-folder-o'"></i>
<{ item.pretty_name }>
</a>
<ul class="nav nav-second-level metismenu">
<li ng-repeat="item2 in item.files" metis="">
<a href="#">
<i class="fa fa-file"></i>
<{ item2.pretty_name }>
</a>
</li>
</ul>
</li>

