How do I toggle an ng-show in AngularJS based on a boolean? How do I toggle an ng-show in AngularJS based on a boolean? angularjs angularjs

How do I toggle an ng-show in AngularJS based on a boolean?


You just need to toggle the value of "isReplyFormOpen" on ng-click event

<a ng-click="isReplyFormOpen = !isReplyFormOpen">Reply</a> <div ng-show="isReplyFormOpen" id="replyForm">   </div>


Basically I solved it by NOT-ing the isReplyFormOpen value whenever it is clicked:

<a ng-click="isReplyFormOpen = !isReplyFormOpen">Reply</a><div ng-init="isReplyFormOpen = false" ng-show="isReplyFormOpen" id="replyForm">    <!-- Form --></div>


If based on click here it is:

ng-click="orderReverse = orderReverse ? false : true"