Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date filter is ignored
Message
De
29/05/2015 15:45:55
 
 
Information générale
Forum:
Javascript
Catégorie:
Autre
Divers
Thread ID:
01620266
Message ID:
01620359
Vues:
44
J'aime (1)
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform