无法使用ng-repeat访问JSON
Unable to access JSON using ng-repeat
我有两个JSON对象。一个JSON对象应该为我提供第二个JSON对象的键。JSON 1 (tableInfo):
[
-{
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 (currentInfo):
[
-{
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中的"name"作为列分隔符(例如|"id"|"article"|"publisher"|)
我知道要获取JSON 1的名称特性,我可以很容易地使用
<tr ng-repeat="item in tableInfo">
<td>{{item.name}}</td>
</tr>
但是如何访问JSON 2中每个元素的每个属性(item.name) ?
<!-- item.name comes from the parent loop -->
<td ng-repeat="anotherItem in currentInfo">
{{anotherItem[item.name]}}
</td>
相关文章:
- 访问JSON对象内部的数组元素
- 访问json数组中的对象
- 如何访问JSON元素
- 使用Backbone.js访问JSON响应的部分
- JS/JON-通过JS访问JSON中的多个数组
- 对于循环未正确访问 JSON 对象
- 使用 jasmine-node / frisby 访问 JSON 值
- 如何访问 JSON 对象数组的第一个元素
- 如何在 for 循环中访问 json 数组字段的名称
- Javascript 不会访问 json 对象
- 无法访问JSON对象的值
- 无法访问json对象中的数据
- 访问JSON对象中的特定值
- 如何通过javascript访问JSON数据
- 从Web服务访问JSON响应
- 我可以't访问JSON中的第一个对象
- 是否有可能访问JSON对象中列出的jQuery选择器
- 为什么我可以't使用点表示法访问JSON字典元素
- 访问JSON数组时出现问题
- 如何在processing.js中访问json数据