如何将值数组作为过滤器传递给angularjs
我的情景
cuisines json:["food", "Alcohol","Thai"]
catorigeres json:["home", "office","school"]
价值与美食和类别:
[{
"_id": "1",
"businessTypeName": "Pizza Hut",
"cus_name": ["food","Thai"],
"cat_name": ["home", "school"],
}, {
"_id": "2",
"businessTypeName": "Chicken Hut",
"cus_name":["Alcohol","Thai"],
"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"],
}]
如果我点击任何人,它会将菜单附加到{{selected}}
我的问题是如何将{{selected}}
中的值过滤到listing_loop div
答案 0 :(得分:0)
我认为你不能单独用html做到这一点。
您可以向范围添加过滤功能:
$scope.customFilter = function(value, index, array) {
// make sure `value.id` is a string
return ["food","Thai","Alcohol"].indexOf(value.id);
}
并在HTML中使用这样的
<div ng-repeat="set in get | filter:customFilter"></div>