这是我的 json:
[{"node":
{'name': 'Nexus S',
'snippet': 'Fast just got faster with Nexus S.',
'age': 1}},
{"node":{'name': 'Motorola XOOM™ with Wi-Fi',
'snippet': 'The Next, Next Generation tablet.',
'age': 2}},
{"node":{'name': 'MOTOROLA XOOM™',
'snippet': 'The Next, Next Generation tablet.',
'age': 3}}
];
这是我的代码:
Search-title: <input type='text' ng-model="name">
<div class='cat' ng-repeat="(key,value) in phones ">
<ul ng-repeat="fin in value | filter:name ">
<li><h3>{{fin.name}}</h3>
{{fin.snippet}}
</li>
</ul>
</div>
如何对此 json 对象应用过滤器?
最佳答案
请参阅此处:http://jsbin.com/kovegi/1/edit?html,js,output CodingNinja 很接近,只需使用 ng-model="searchObj.node.name"
代替 ng-model="searchObj.name"
<div ng-controller="firstCtrl">
Search-title: <input type='text' ng-model="searchObj.node.name">
<div class='cat' ng-repeat="(key,value) in phones | filter:searchObj ">
<ul ng-repeat="fin in value">
<li><h3>{{fin.name}}</h3>
{{fin.snippet}}
</li>
</ul>
</div>
关于javascript - 如何使用 ng-repeat 对二维 json 对象应用过滤器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25055333/