I have an HTML table as follows:
<table>
<tr ng-show="showCats"><td>Cat</td><td>1</td></tr>
<tr ng-show="showDogs"><td>Dog</td><td>2</td></tr>
<tr ng-show="showCats"><td>Cat</td><td>4</td></tr>
<tr ng-show="showDogs"><td>Dog</td><td>3</td></tr>
<tr ng-show="showCats"><td>Cat</td><td>5</td></tr>
<tr ng-show="showLizards"><td>Lizard</td><td>1</td></tr>
<tr ng-show="showLizards"><td>Lizard</td><td>3</td></tr>
<tr ng-show="showMice"><td>Mouse</td><td>5</td></tr>
<tr ng-show="showMice"><td>Mouse</td><td>1</td></tr>
<tr ng-show="showDogs"><td>Dog</td><td>3</td></tr>
</table>
And links as follows:
<a href="#" ng-click="showRows('all')">Show all</a>
<a href="#" ng-click="showRows('cats')">Cats</a>
<a href="#" ng-click="showRows('dogs')">Dogs</a>
<a href="#" ng-click="showRows('lizards')">Lizards</a>
<a href="#" ng-click="showRows('mice')">Mice</a>
What's the proper way in Angular to hide/show each row when an animal type is clicked? I'm aware of filter, but I'm under the impression that that only works for tables generated in Angular using ng-repeat. (This table is being generated server-side.)
I have a working solution that manually sets each showAnimal variable to true/false based on what was clicked, but this seems like an inefficient, unscalable approach. Thanks!