[英]AngularJS toggle ng-repeat visibility with checkbox
So I have a list of notices in AngularJS which I create with ng-repeat
. 所以我有一个用
ng-repeat
创建的AngularJS中的通知列表。 The notices have a visibility status which determines whether the notice is shown in the list. 通知具有可见性状态,该状态确定通知是否显示在列表中。 Every notice has controls which allow that notice to be hidden, a simple button that changes the
notice.status.visibility
to false. 每个通知都具有允许隐藏该通知的控件,一个简单的按钮可将
notice.status.visibility
更改为false。
I also have a checkbox input that is supposed to show hidden notices. 我还有一个复选框输入,应该显示隐藏的通知。 However, I am unsure on how to implement this and how would it work.
但是,我不确定如何实现它以及它如何工作。
Here's the HTML: 这是HTML:
<ul>
<input type="checkbox" value="Show Hidden" />
<li ng-repeat="notice on notices | filter: filter.search">
<div ng-show="notice.status.visibility">
<!-- notice details -->
</div>
</li>
</ul>
Maybe with something like this: 也许是这样的:
<ul>
<input type="checkbox" value="Show Hidden" ng-model="showHidden" />
<li ng-repeat="notice on notices | filter: filter.search">
<div ng-show="showHidden || notice.status.visibility">
<!-- notice details -->
</div>
</li>
</ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.