javascript - Filtering ng-repeat by number of days -
so have simple list created ng-repeat contains text filter , drop down menu numbers in supposed show list elements number period of time (say last 10 days):
<input type="text" ng-model="filter.search" /> <select ng-model="filter.days"> <option value="1">1</option> ... <option value="30">30</option> </select> <ul> <li ng-repeat="notice in notices | filter: filter.search"> ... {{notice.modified.date | date:'dd.mm.yyyy'}}</li> ... </li> </ul>
however unsure how apply <select>
filter ng-repeat.
can angular "out of box" or require custom filter , if so, pointers on those?
the 'filter' filter supports passing in functions arbitrary predicates.
http://docs.angularjs.org/api/ng.filter:filter
specifically expression argument has this:
function: predicate function can used write arbitrary filters. function called each element of array. final result array of elements predicate returned true for.
so this
<li ng-repeat="notice in notices | filter: filter.search | filter:withindays"> $scope.withindays = function(item) { // use $scope.filter.days + notice.modified.date day comparison, , return true/false. };
Comments
Post a Comment