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和算法)。我的代碼缺少什麼?