Here's the code snippet I am currently working with:
<tr ng-repeat="version in allVersions" ng-class="{{ version['active'] == 'true' ? 'active' : 'inactive' }}">
</tr>
The ng-class
is functioning as expected based on the object provided. The output is as desired.
However, my goal is to have the ng-class
value of inactive
hidden initially. Upon clicking a button, it should toggle visibility - displaying only active
fields when clicked again. Essentially, I want a toggle functionality for this.
I attempted the following:
<tr ng-repeat="version in allVersions" ng-class="{{ version['active'] == 'true' ? 'active' : 'inactive' }}" ng-show="version['active'] == 'true'">
</tr>
While this displays only active
elements, I am unsure how to proceed with showing inactive
upon button click.
The state of inactive
should remain constant. Clicking a button labeled showall
will display it, while clicking the active
button will hide it, leaving only active
elements visible.
As a newcomer to Angular, I'm seeking guidance on an easier approach to achieve this functionality. Any suggestions would be greatly appreciated.
Thank you in advance.