Filtering a list with mutiple independant parameters (check-boxes)

23 views
Skip to first unread message

ste...@gmail.com

unread,
Jun 7, 2014, 11:23:09 PM6/7/14
to ang...@googlegroups.com

I'm using AngularJS to filter the results of a wine's list. The wines are categorized by colors (red, white, rose, champagne), and other parameters (countries).

When one color is checked with the check-box (red for example), a filtered list of red wine appears. But when two colors are selected, no results appears (red and white for example). Same problems if a check France and Italie both.

my wishes:

  • My principal wish, would be to able to choose more than one parameter. For example if a check red and white for the color wines, and leger and France too, would be displayed the filtered list linked to the theses checked box (the list of the red and white wines from France, and leger)

here the code example:


<div ng-controller="MainCtrl">

<input ng-model="characteristics.red" type="checkbox" >red</input>
<input ng-model="characteristics.white" type="checkbox" >white</input>
<input ng-model="characteristics.rose" type="checkbox" >rose</input>
<input ng-model="characteristics.champagne" type="checkbox" >champagne</input>
<br><br>
<input ng-model="characteristics.leger" type="checkbox" >leger</input>
<input ng-model="characteristics.fort" type="checkbox" >fort</input>
<br><br>
<input ng-model="characteristics.france" type="checkbox" >france</input>
<input ng-model="characteristics.italie" type="checkbox" >italie</input>
<br><br>
<div ng-repeat="wine in filtered= (wines |filteredstoves:characteristics) | filteredstoves:characteristics"> {{wine.name}} - {{wine.characteristics}} </div> <br><br> Filtered list has {{filtered.length}} items </div>


Demo of the code: http://jsfiddle.net/stefanos/kTYdd/31/

it sounds very hard to code, i tried during hours without results


regards,

Stéphane


Karol Siwek

unread,
Jun 8, 2014, 7:05:44 AM6/8/14
to ang...@googlegroups.com
try doing the other way around - instead od removing wines from result when they don't mach filtering, just add to result wines which do match filtering.


unfortunetely, you'll need special case for situation when no checkboxes are checked.

Stéphane Cabaret

unread,
Jun 8, 2014, 11:39:34 AM6/8/14
to ang...@googlegroups.com
thanks fo you reply


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/l18du7c6z4w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages