Working with angularjs, take a look at my view code :
<div style="width:70px;">
Show Online <input type="checkbox" ng-model="showonline" />
</div>
<div ng-repeat="user in users|filter:showonline">
<span type="button" class="{(isOnline()) ? 'available' : 'unavailable'}">user.id</span>
</div>
The snippet above will output HTML like the following within the div containing ng-repeat:
<span type="button" class="available">111</span>
<span type="button" class="available">121</span>
<span type="button" class="unavailable">88</span>
<span type="button" class="available">878</span>
The classes are applied based on the online status of each user. By default, it displays all elements with the "available" and "unavailable" classes. I aim to implement a checkbox as a filter to selectively display elements by their class name (checking the box should only show "available" users). When unchecked, both "available" and "unavailable" elements should be visible. I am familiar with filtering data in angularjs but unsure how to filter by classname using a checkbox. How can I achieve this?