Javascript 无法使用ng repeat访问JSON
我有两个JSON对象。一个JSON对象应该为第二个JSON对象提供一个键。 JSON 1表格信息:Javascript 无法使用ng repeat访问JSON,javascript,json,angularjs,angularjs-ng-repeat,Javascript,Json,Angularjs,Angularjs Ng Repeat,我有两个JSON对象。一个JSON对象应该为第二个JSON对象提供一个键。 JSON 1表格信息: [ -{ name: "id", dataType: "Integer", isEditable: false } -{ name: "article", dataType: "String", isEditable: true } -{ name: "publisher", dataType: "String", isEditable: false
[
-{
name: "id",
dataType: "Integer",
isEditable: false
}
-{
name: "article",
dataType: "String",
isEditable: true
}
-{
name: "publisher",
dataType: "String",
isEditable: false
}
-{
name: "metadata.comments",
dataType: "Integer",
isEditable: false
}
]
JSON 2当前信息:
[
-{
id: 0,
article: "JavaScript Conquers the World",
publisher: "Daily Times",
metadata: {
comments: 4
}
}
-{
id: 1,
article: "The Problem with Foobar",
publisher: "New York Times",
metadata: {
comments: 27
}
}
]
我想使用ng repeat或类似的指令将JSON 2中的信息显示为一个表,其中JSON 1中的名称充当列分隔符,例如| id | article | publisher|
我知道,要获得JSON 1的名称功能,我可以很容易地进行
<tr ng-repeat="item in tableInfo">
<td>{{item.name}}</td>
</tr>
但是如何访问JSON 2中每个元素的每个属性项。名称?使用此方法访问metadata.comments时,我遇到了一些问题,但它确实帮助我取得了进展。谢谢
<!-- item.name comes from the parent loop -->
<td ng-repeat="anotherItem in currentInfo">
{{anotherItem[item.name]}}
</td>