简体   繁体   中英

AngularJS toggle ng-repeat visibility with checkbox

So I have a list of notices in AngularJS which I create with ng-repeat . 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.

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:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM