[英]AngularJS - How can I filter through a nested json array
AngularJS newbie here. AngularJS新手在这里。 Here is a JSON file that I've been working on and what I'm trying to do is to filter the search by ingredient using AngularJS.
这是我一直在努力的JSON文件,我正在尝试做的是使用AngularJS按成分过滤搜索。 Help please?
请帮助?
{
"id": 01,
"recipe-name": "Fried Fish",
"ing": {
"i1": "1 fish",
"i2": "1 egg",
"i3": "1\/2 cup flour",
"i4": "salt and pepper",
"i5": "chili leaves"
}
}
Here's my code for the filtered results 这是我的过滤结果代码
<div class="results" ng-repeat="r in recipes | filter:q.ing">
You don't need a filter. 您不需要过滤器。
You just need to ng-repeat
through the recipes.ing
nested object. 您只需要
ng-repeat
通过recipes.ing
嵌套对象。
<div class="results" ng-repeat="r in recipes.ing">
<p>{{r}}</p>
</div>
Simple fiddle: http://jsfiddle.net/zq39zspc/1/ 简单的小提琴: http : //jsfiddle.net/zq39zspc/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.