【发布时间】:2023-03-11 11:15:01
【问题描述】:
我有以下 JSON 对象可以使用 ng-repeat 进行访问。我得到了第一列的所有名称,而不是分组到不同的列中。
$scope.tableItems = [
{
"title": "BUILDING ID",
"subtitle": [
{
"name": "Nexon"
},
{
"name": "Kodak"
},
{
"name": "Lion"
}
]
},
{
"title": "TECHNOLOGY",
"subtitle": [
{
"name": "Robotic"
},
{
"name": "AI"
},
{
"name": "Algorithm"
]
}
];
我尝试过使用jade这样访问它,
table
thead
tr
th(ng-repeat = "x in tableItems") {{ x.title }} //- get BUILDING ID and TECHNOLOGY
tbody(ng-repeat = "x in tableItems") //- get all the NAMEs
tr(ng-repeat = "(key, value) in x.subtitle")
td {{ value.name }}
然后返回结果
BUILDING ID TECHNOLOGY
Nexon
Kodak
Lion
Robotic
AI
Algorithm
我希望它能够根据表头打印表格,所以在
“BUILDING ID”将只有 3 个项目(Nexon、Kodak 和 Lion)和“TECHNOLOGY”
将有(机器人、人工智能和算法)。我的代码缺少什么?
【问题讨论】:
标签: json html-table nested angularjs-ng-repeat pug