javascript - Filtering in Angular using a slight complex boolean condition -
i struggling filters in angularjs. essentially, have checkbox this:
<div class="col-sm-2" style="text-align: right"> <label for="include-deleted-search" class="control-label">include deleted</label> </div> <div class="col-sm-2"> <input ng-model="search.includedeleted" type="checkbox" id="include-deleted-search"/> </div>
which trying use filter airlines if (the item in filter deleted, , includedeleted true) or item in filter not deleted.
my table looks this, note { isdeleted: search.includedeleted } filter not working i'd like.
<table class="table table-hover table-striped table-bordered"> <thead> <tr> <th>ariline id</th> <th>airline name</th> <th>country</th> <th>telephone</th> <th>24hr telephone</th> <th>email address</th> <th>deleted</th> </tr> </thead> <tr dir-paginate="airline in airlines | filter: { airlinename: search.airlinename||'' } | filter: { country: search.countryname||'' } | filter: { isdeleted: search.includedeleted||!isdeleted } | itemsperpage: pagesize" current-page="currentpage"> <td>{{ airline.airlineid }}</td> <td>{{ airline.airlinename }}</td> <td>{{ airline.country }}</td> <td>{{ airline.telephonenumber }}</td> <td>{{ ariline.telephone24hour }}</td> <td>{{ airline.emailaddress }}</td> <td>{{ airline.isdeleted }}</td> </tr> </table>
how can express filter condition? need write custom filter? else working correctly.
if understand intention correctly, can set expression based on search.includedelted
. if it's true, return undefined (assuming isdeleted
boolean value) not filter of items, otherwise return false, return falsy:
filter:{isdeleted: search.includedeleted?undefined:false}
Comments
Post a Comment