0
我有以下使用ng-repeat访问的JSON对象。我在第一列中获得了所有名称,而不是分组到不同的列中。如何使用ng-repeat正确访问嵌套元素?
$scope.tableItems = [
{
"title": "BUILDING ID",
"subtitle": [
{
"name": "Nexon"
},
{
"name": "Kodak"
},
{
"name": "Lion"
}
]
},
{
"title": "TECHNOLOGY",
"subtitle": [
{
"name": "Robotic"
},
{
"name": "AI"
},
{
"name": "Algorithm"
]
}
];
我试图访问它像这样用玉,
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
我希望它能够根据表头打印表,所以根据
“建筑物ID”将只有3项(Nexon,柯达和狮子)和“技术”
会有(机器人,AI和算法)。我的代码缺少什么?