Ramanaa Gj Ramanaa Gj - 2 months ago 33
AngularJS Question

AngularJS: how to give array of values to filter

How to pass array of values as filter in angularjs

My scenario

cuisines json:

["food", "Alcohol","Thai"]

catorigeres json :
["home", "office","school"]

values with cuisines and categories :

"_id": "1",
"businessTypeName": "Pizza Hut",
"cus_name": ["food","Thai"],
"cat_name": ["home", "school"],

}, {
"_id": "2",
"businessTypeName": "Chicken Hut",
"cat_name": ["office", "home"],
}, {
"_id": "3",
"businessTypeName": "Fish Hut",
"bussiness_url": "/dist/images/loop_image_sample_3.png",
"cus_name": ["Thai"],
"cat_name": ["office", "school"],


cuisines and categories are of in checkbox if i click anyone it will append the array of values to {{selected}}

my question is how to filter values in
to listing_loop div

my plunker demo


I don't think you can do that in html alone.

You can add a filtering function to the scope:

$scope.customFilter = function(value, index, array) {
      // make sure `value.id` is a string
      return ["food","Thai","Alcohol"].indexOf(value.id);

and using like this in HTML

<div ng-repeat="set in get | filter:customFilter"></div>