Open msholly opened 7 years ago
I have a list of contacts with a text input to filter the result, I would like to be able to filter result by contact name or phone number. Any updates on this?
@MurhafSousli use $or
- https://github.com/VadimDez/ngx-filter-pipe#or-matching
@MurhafSousli No! your solution doesn't work!
Another way to describe would be a wildcard search, without having to specify the keys to search. Since data could be user generated or dynamic, would be nice to just search no matter what.
@MurhafSousli I did it .
My register have Name and Number , but I created one field more : name : DAVID phone : + 1 (510) 760 7607 full : david + 1 (510) 760 7607 < --- I use this field to filter, so I've one textfield where I can write something like 'david' or '510' or '+1'......
Maybe it help you.
@dvalvarenga offcourse you can do that but it means modifing the data array, which might not be nice if your data came from service or used by other features. @VadimDez its best if the pipe did this itself, add an option to contacate fields ( may be array|filterBy:{term: searchTerm, fields: ['field1','field2']}
)
Didn't AngularJS <v1.6 look through all available fields, and you had to expressly tell it to only search certain fields? However I'm sure performance-wise, that was a poor choice in old AngularJS.
But I did like @Abenezer suggestion, at least for my use case. Just a clean way to target fields, but also keep in mind that the data structure could be dynamic. So wildcarding or fully searching for any matches might be more widely helpful.
Just created a Pull request implementing Abenezer Suggestion. And ability to close this issue
the issue still open, the problem are really big :(
Any news on this feature ? I'm really interested :/
Not sure if vadimDez has seen the pull request. If not you can pull directly from that if your urgent.
i got the solutions, but its just a smart way :) put all your data in particular filed as with pipe divided and filter on that particular field you got the result :)
Thanks for your work on this library. I have some user data already loaded in the view, and I'd like to filter by anything that matches. Do I have to specify each field in a getUsers() style function from your examples, or can it just look at the whole record and return anything that matches.
Here's some example code.