pure javascript:
var wines = [];
function filterrData(wines, name, type, country, style) {
var filteredData = wines.filter(function(entity){
// just nest all of the results here
var wineName = name || entity.name;
if(entity.name === wineName) return true;
else return false
});
}
On Sunday, June 8, 2014 5:40:23 PM UTC+2, [email protected] wrote:
>
> I have a json wine list, and my wish is to build a code with AngularJS to
> filter the results
>
> the json file
>
> [{ "name": "Wine a", "type": "red", "country": "france", "style": "strong"
> },{ "name": "Wine a", "type": "white", "country": "italie", "style": "medium"
> },{ "name": "Wine a", "type": "white", "country": "france", "style": "light"
> },{ "name": "Wine a", "type": "rose", "country": "usa", "style": "strong" },{
> "name": "Wine a", "type": "champagne", "country": "chili", "style": "medium"
> },{ "name": "Wine a", "type": "red", "country": "brazil", "style": "strong"
> },{ "name": "Wine a", "type": "red", "country": "france", "style": "strong" }
> ]
>
> the check-boxes
>
> <div ng-controller="MainCtrl">
> <input ng-model="red" type="checkbox" >red</input>
> <input ng-model="white" type="checkbox" >white</input>
> <input ng-model="rose" type="checkbox" >rose</input>
> <input ng-model="champagne" type="checkbox" >champagne</input>
>
> <input ng-model="france" type="checkbox" >france/input>
> <input ng-model="italie" type="checkbox" >italie</input>
> <input ng-model="brazil" type="checkbox" >brazil</input>
> <input ng-model="chili" type="checkbox" >chili</input>
>
> <input ng-model="strong" type="checkbox" >strong</input>
> <input ng-model="medium" type="checkbox" >medium</input>
> <input ng-model="light" type="checkbox" >light</input>
> </div>
>
> *my wish*
>
> My wish is to build a dynamic multi parameter filter list,the result of
> the list would match with the values of the check-boxes.
>
> -
>
> if i check red and strong, would appears in the list, only the wines
> from the json list with these parameter (a list of red and strong wines).
> -
>
> if i check red, white and france, would appears in the list, only the
> wines from the json list with these parameter ( a list of red and white
> wines from france).
>
> i tried many solution, with no results. It seems to be hard to code!!
>
--
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.