本文介绍了如何根据布尔值在AngularJS中切换ng显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表单,用于回复仅当 isReplyFormOpen
为true时才显示的消息,并且每次单击回复按钮时,我都要切换表单是否显示与否。如何才能做到这一点?
I have a form for replying to messages that I want to show only when isReplyFormOpen
is true, and everytime I click the reply button I want to toggle whether the form is shown or not. How can I do this?
推荐答案
您只需在ng-click事件中切换isReplyFormOpen的值
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>
这篇关于如何根据布尔值在AngularJS中切换ng显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!