>>>I don't want to have filter on ng-repeat anymore, I'd like to apply filter by pressing a button.
>>>
>>>Do you mean my applyFilter procedure is too complex now?
>>>
>>
>>Just thinking it could be simpler. You could create a date range filter which would create a new array of valid dates for the input array rather then removing unwanted elements (several examples online e.g;
http://stackoverflow.com/questions/25515431/ng-repeat-filtering-data-by-date-range). You could then pipe .filteredTransactions to that filter.
>>
>>Advantages : You have a generic date range filter that could be used elsewhere and cleaner code to replace the below.
>>And since the original .filteredTransactions would not be modified by the date range logic you could, in circumstances where only the date range has changed, avoid rebuilding that array.
>>
>>Depends on your circumstances - might not be worth the candle........
>>
>
>Sounds like a good idea and actually I saw this example on stackoverflow before. The only problem is that I could not figure out yet from angularJS documentation how to call that custom filter in JavaScript. Can you show a sample of calling this filter in js file?
TOMH, using the example in the link (your code could be simpler)
Add a rangeFilteredTransactions to $scope and:
$scope.rangeFilteredTransactions = $filter('myFilter')($scope.filteredTransactions,$scope.startDate,$scope.endDate);
If $scope.startDate is null set it to a sufficiently early date. Ditto endDate