How to keep a checkbox checked after filtering

0
<div ng-repeat="post in posts | filter:{components:component} | filter:{classification:class}:true">
     <ul>
          <div class="selected-{{'{{charter.selected}}'}}" ng-hide="post.charters.length <= 0" ng-repeat="charter in post.charters">
               <input type="checkbox" ng-model="charter.selected" ng-change="addSelectedCharters(post, charter)">
                    {{'{{charter}}'}}
          </div>
     </ul>
</div>

When I filter, all checkboxes that were previously marked are gone. How can I solve? Thanks!

    
asked by anonymous 11.10.2017 / 16:28

1 answer

0

I suggest you create a property in your items, which could be:

<div ng-repeat="post in posts | filter:{components:component} | filter:{classification:class}:true">
     <ul>
          <div class="selected-{{'{{charter.selected}}'}}" ng-hide="post.charters.length <= 0" ng-repeat="charter in post.charters">
               <input type="checkbox" ng-model="post.selected" ng-change="addSelectedCharters(post, charter)">
                    {{'{{charter}}'}}
          </div>
     </ul>
</div>

The difference is here ng-model="post.selected" .

    
11.10.2017 / 16:34