ng-repeat "and" filter for multiple select field

3,506 views
Skip to first unread message

Mischa Brammer

unread,
Apr 2, 2013, 10:42:43 AM4/2/13
to ang...@googlegroups.com
Hi.
I'm trying to filter data with a multiple select field in angularjs and I want to filter my data by locale. But if I select ['en_US', 'es_ES'], I get nothing. I think it is filtering like "locale = en_US AND local = es_ES". I want something like "locale = en_US OR local = es_ES". How is this possible?

http://plnkr.co/edit/cxpAyI?p=preview

Sander Elias

unread,
Apr 2, 2013, 11:56:16 AM4/2/13
to ang...@googlegroups.com
Hi Stinson,

your plunker is not doing anything for me, it look like angular is not included at all (you should load it from the CDN in your plunker) or start off with the plunker at the top!

Regards
Sander Elias

Stinson

unread,
Apr 3, 2013, 2:54:07 AM4/3/13
to ang...@googlegroups.com
Hi Sander,

now it's working again. I think I deleted the wrong line at my final cleanup ;)

Sander Elias

unread,
Apr 3, 2013, 10:33:20 AM4/3/13
to ang...@googlegroups.com
Hi Stinson,

is this what you you wanted to do?
I created a small filter, just as an example solution for you.

If you want to know more, just drop a note!

Stinson

unread,
Apr 4, 2013, 5:11:22 AM4/4/13
to ang...@googlegroups.com
Hi Sander,

yes this is the right way, but now I can't filter out the name anymore. If I select all locales and type "y" in the name input field, only names containing "y" with the selected locales should be shown.
And is it possible to show all entries by default, if no locale is selected? This should be possible to search by name.

Sander Elias

unread,
Apr 4, 2013, 7:26:14 AM4/4/13
to ang...@googlegroups.com
Hi Stinson,

Sure that's possible, just adapt the filter to whatever gets your fancy. This is one off the possible solutions. I didn't build that by default, because I didn't know what you wanted. 
But now I know, here you go!. However, this is more of a JavaScript question now as it is an angular one ;)

Regards
Sander Elias

Stinson

unread,
Apr 5, 2013, 2:22:29 AM4/5/13
to ang...@googlegroups.com
Perfect! Thank you very much!
Reply all
Reply to author
Forward
0 new messages