I have a angularJS list that I would like to implement several filters, one will be a custom filter.
<li ng-repeat="item in cumulus.items | orderBy: predicate:reverse
| filter:listSearch | filter:filteredDates"
ng-show="cumulus.items.length > 0">
</li>
My filter listSearch is working properly and I already made a function for the filteredDates based in these two inputs and on button click:
<input type="date" ng-model="filter_startDate" />
<input type="date" ng-model="filter_endDate" />
<button id="search" ng-click="dateRange(filter_startDate,filter_endDate, cumulus.items)" >Search</button>
My function is returning the right items on the console, all I need is to update the list with the returned value. Here is the function:
$scope.dateRange = function (initialDateVal, endDateVal, cumulusItems) {
filteredDates = [];
var parsedinitialDateVal = Date.parse(initialDateVal);
var parsedendDateVal = Date.parse(endDateVal);
console.log("Initial date:", initialDateVal, parsedinitialDateVal);
console.log("End date:", endDateVal, parsedendDateVal);
if (cumulusItems && initialDateVal && endDateVal) {
angular.forEach(cumulusItems, function (item) {
parsedItemCreationDate = Date.parse(item.creationDate);
if (parsedItemCreationDate >= parsedinitialDateVal
&& parsedItemCreationDate <= parsedendDateVal) {
filteredDates.push(item);
}
});
}
console.log(filteredDates);
return filteredDates;
};