这里是 AngularJS 新手。这是我一直在处理的 JSON 文件,我想做的是使用 AngularJS 按成分过滤搜索。请帮忙?
{
"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"
}
}
这是我的过滤结果代码
<div class="results" ng-repeat="r in recipes | filter:q.ing">
最佳答案
您不需要过滤器。
您只需通过 recipes.ing
嵌套对象进行 ng-repeat
即可。
<div class="results" ng-repeat="r in recipes.ing">
<p>{{r}}</p>
</div>
简单的 fiddle :http://jsfiddle.net/zq39zspc/1/
关于javascript - AngularJS - 如何过滤嵌套的 json 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34904585/