0

I've taken some example code from the AngularJS docs, this allows for basic filtering on multiple field types. How can I add a date range to this? I've tried adding multiple filters with a condition in {} but this isn't working.

Example code

<div ng-init="friends = [{name:'John', phone:'555-1276', date:'2015-05-12'},
                     {name:'Mary', phone:'800-BIG-MARY', date:'2014-02-24'},
                     {name:'Mike', phone:'555-4321', date:'2013-08-03'},
                     {name:'Adam', phone:'555-5678', date:'2015-03-16'},
                     {name:'Julie', phone:'555-8765', date:'2014-12-27'},
                     {name:'Juliette', phone:'555-5678', date:'2011-01-19'}]">
                     </div>


<label>Any: <input ng-model="search.$"></label> <br>
<label>Name only <input ng-model="search.name"></label><br>
<label>Phone only <input ng-model="search.phone"></label><br>

<!-- I've added this START-->
<label>Date between<input ng-model="search.dateFrom"></label><br>
<label>and<input ng-model="search.dateTo"></label><br>
<!-- END -->

<table id="searchObjResults">
  <tr><th>Name</th><th>Phone</th></tr>
  <tr ng-repeat="friendObj in friends | filter:search">
    <td>{{friendObj.name}}</td>
    <td>{{friendObj.phone}}</td>
  </tr>
</table>

I've omitted any date range logic on the ng-repeat filter.

Rob
  • 738
  • 3
  • 10
  • 23

0 Answers0