我有以下JSON文件要阅读,我想只显示我想要的一些特定的JSON文件。
[
{
"recommendation_id": "cuhwbchuwbcuhw-ccnahcbhb-12",
"title": "hellow world",
"content": "Hello angular",
"name": "John",
"home": "USA"
},
{
"recommendation_id": "cuhwcacabchuwbw-ccnahcbhb-32",
"title": "ng-show",
"content": "ng-show is amazing",
"name": "Google",
"home": "USA"
},
......
{
"recommendation_id": "guwqiwu212wbcuhw-ccnahcbhb-12",
"title": "Awesome",
"content": "Hello Awesome",
"name": "Mike",
"home": "Canada"
}
]
以下是我使用Jade访问表格标题的方法。
table(id="allRecommendations")
thead
tr
th(ng-repeat='(key, value) in recommendationsAll[1]') {{key}}
输出
recommendation_id title content name home
但我只想要前三项,它们应如下所示:
recommendation_id title content
那么,我的过滤器会错过什么?我有兴趣获取对象属性而不是我的属性详细信息。如何过滤以显示特定的JSON属性?
答案 0 :(得分:-1)
这将解决问题。
table(id="allRecommendations")
thead
tr
th(ng-repeat="(key, value) in recommendationsAll[1]", ng-show="key == 'recommendation_id' || key == 'title' || key == 'content' " ) {{key}}