Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date filter is ignored
Message
 
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01620266
Message ID:
01620362
Views:
40
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?

>>>See my reply to your other thread.....
>>
>>Trying to figure out syntax here:
>>
>>
>>if ($scope.searchTerm.message)
>>                    {
>>                        $scope.filteredTransactions = $filter('filter')($scope.invoiceTransactionsObject.transactions, { message: $scope.searchTerm.message, item: $scope.searchTerm.message });
>>                    }
>>
>>I need a match in either of these 2 properties, not in all of them.
>>
>>UPDATE. I figured out (based on stackoverflow thread) that first problem, but now I am having a bug in my dates logic and can not figure out what is wrong. Can you help? It looks like the second condition with the endDate is not working:
>>
>>
>> $scope.applyFilter = function()
>>                {
>>                    $scope.filteredTransactions = $scope.invoiceTransactionsObject.transactions;
>>                    if ($scope.searchTerm.message)
>>                    {
>>                        $scope.filteredTransactions = $filter('filter')($scope.invoiceTransactionsObject.transactions, ({ message: $scope.searchTerm.message } || { item: $scope.searchTerm.message }));
>>                    }
>>
>>                    if ($scope.startDate != null || $scope.endDate != null)
>>                    {
>>                        for (var i = $scope.filteredTransactions.length - 1; 0, i--;)
>>                        {
>>                            if ($scope.startDate!=null && $scope.filteredTransactions[i].dateTime < $scope.startDate)
>>                            {
>>                                $scope.filteredTransactions.splice(i,1); // remove that element
>>                                continue;
>>                            }
>>                            if ($scope.endDate!=null && $scope.filteredTransactions[i].dateTime > $scope.endDate)
>>                            {
>>                                $scope.filteredTransactions.splice(i,1); // remove that element
>>                                continue;
>>                            }
>>                        }
>>                    }
>>                    $scope.filteredTotal = $scope.getTotal($scope.filteredTransactions, 'extension');
>>                }
>>
>>
>>UPDATE2. I think I know the problem, testing now.
>>
>>UPDATE3. Solved the problem.
>
>Looks overly complicated. Why not something like :
>http://stackoverflow.com/questions/21411686/how-to-filter-multiple-values-or-operation-in-angularjs-with-checkbox
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform