Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date filter is ignored
Message
From
31/05/2015 02:45:50
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01620266
Message ID:
01620401
Views:
45
This message has been marked as a message which has helped to the initial question of the thread.
>>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform