我有以下数组:
var boofers = [
{
"id" : "kurfki8z6786",
"query" : {"name": "foo", "status": "open"},
"uid" : "1416422209395",
},
{
"id" : "kurfki8z6874",
"query" : {"name": "puff", "status": "closed"},
"uid" : "1416422209387",
},
{
"id" : "kurfki8z6123",
"query" : {"name": "joe", "status": "closed"},
"uid" : "1416422209301",
}
]
我需要在uid
个对象的boofers
查询status
boofer
的{{1}}值打印为closed
,所以我正在尝试以下内容但是没有得到结果,因为{{boofer.uid}}
没有打印出来:
<div ng-repeat="boofer in boofers | filter: {query.status: 'closed'}">{{boofer.uid}}</div>
有人可以告诉我我在这里犯的错误以及如何解决它?
答案 0 :(得分:1)
从JSON数组中的每个)
中删除id
:
boofers = [
{
"id" : "kurfki8z6786",
"query" : {"name": "foo", "status": "open"},
"uid" : "1416422209395",
},
{
"id" : "kurfki8z6874",
"query" : {"name": "puff", "status": "closed"},
"uid" : "1416422209387",
},
{
"id" : "kurfki8z6123",
"query" : {"name": "joe", "status": "closed"},
"uid" : "1416422209301",
}
];
这里: http://jsfiddle.net/nk5Loxoy/
注意:如果您在编辑之前在查询中使用数组,则应使用自定义过滤器
答案 1 :(得分:0)
您可以使用ng-if?
<div ng-repeat="boofer in boofers" ng-if="boofer.query.status==='closed'">{{boofer.uid}}</div>