I have an array of objects with multiple properties. All of these objects have a object.comment property, but in some is filled with a string ('comment' : 'comment text'), and the others are empty ('comment' : '').
I list the results with an ng-repeat like so:
<div class="row msf-row"
ng-repeat="record in filteredRecords = (recordlist | filter:dateFilter | filter: search )"
>
What I'm trying to accomplish is to add a checkbox filter to show only the results which object.comment property is filled when the checkbox is checked, and all results when is unchecked.
Here's how my filter looks so far:
<form role="form">
<div class="form-group col-md-3">
<input type='daterange'
placeholder="Date range"
class="form-control"
format="DD/MM/YYYY"
ng-model="dates"
ranges="ranges" />
</div>
<div class="form-group col-md-1">
<input class="form-control" placeholder="Time" ng-model="search.time">
</div>
<div class="form-group col-md-1">
<input class="form-control" placeholder="Car" ng-model="search.car">
</div>
<div class="form-group col-md-2">
<input class="form-control" placeholder="Driver" ng-model="search.driver">
</div>
<div class="form-group col-md-2">
<input class="form-control" placeholder="From" ng-model="search.from">
</div>
<div class="form-group col-md-2">
<input class="form-control" placeholder="Destination" ng-model="search.destination">
</div>
<div class="form-group col-md-1">
<input class="form-control" placeholder="Pax" ng-model="search.pax">
</div>
<div class="col-md-1">
<div class="checkbox">
<label>
<input type="checkbox"
ng-model="search.cancelled"
ng-change="search.cancelled = search.cancelled ? true : undefined"
> Cancelled
</label>
</div>
</div>
<div class="col-md-2">
<div class="checkbox">
<label>
<input type="checkbox"
ng-model="search.comment"
ng-change="search.comment = search.comment ? true : undefined"
> Commented records
</label>
</div>
</div>
</form>
As you can see, I already have a filter that works on whether the object.cancelled is true or false, but I didn't manage to do the same for when the object.comment is empty or has a string.
Any pointers?