I put your code into a plunker: 
http://plnkr.co/edit/HpQgPE7zCW5q7N7fvpTL?p=preview

For future reference, this is a very nice thing to do and will get more 
people to help you. If someone can easily hop in and see your code working 
(or not working) and tinker with it, they’ll be much likelier to respond. A 
lot of code on a page isn’t much good to anyone.

I had to take a stab at what your JSON data looked like based on the table, 
but it’s pretty straight forward stuff. If my guess was correct, then I 
know what your problem is. If that “cost” property is a float and not a 
string, the toLowerCase call in searchMatch will throw an error. If that’s 
the issue, you should be seeing an error along the lines of "TypeError: 
undefined is not a function at searchMatch” in your console.

On the other hand, if I make the costs strings and revert the filtering to 
how you originally had it, searching works fine. But it would be better to 
leave the costs as floats and fix your searchMatch function… if that is 
indeed the issue.

Also, FYI, when Sander suggested changing the filtering to add to an array, 
I think he meant to do so instead of using $filter(‘filter’). The way you 
were originally using filter, by returning true or false, was correct, but 
$filter doesn’t buy you anything here over pushing matches directly onto 
the $filteredItems array.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to