这是我正在使用的数据。这是3个不同的阵列。
"areas": {
"default": [
{
"area": "Master Bedroom",
"uuid": "986e3f42-1797-49ae-b060-181a33b9",
"description": "",
"new": [
{
"value": "986e3f42-1797-49ae-b060-181a33b9",
"label": "Master Bedroom",
"selected": false
},
{
"value": "0c7abecb-6078-4718-8537-97a0d8ea",
"label": "Bedroom",
"selected": false
},
{
"value": "95de4e05-a5f4-4d67-bd8b-cb3906c4",
"label": "Powder Room",
"selected": false
},
{
"value": "b4e794b2-7a5f-4567-9422-cb1c67c8",
"label": "Kitchen",
"selected": false
},
{
"value": null,
"label": "Select",
"selected": true
}
]
},
{
"area": "Kitchen",
"uuid": "b4e794b2-7a5f-4567-9422-cb1c67c8",
"description": "",
"new": [
{
"value": "986e3f42-1797-49ae-b060-181a33b9",
"label": "Master Bedroom",
"selected": false
},
{
"value": "0c7abecb-6078-4718-8537-97a0d8ea",
"label": "Bedroom",
"selected": false
},
{
"value": "95de4e05-a5f4-4d67-bd8b-cb3906c4",
"label": "Powder Room",
"selected": false
},
{
"value": "b4e794b2-7a5f-4567-9422-cb1c67c8",
"label": "Kitchen",
"selected": false
},
{
"value": null,
"label": "Select",
"selected": true
}
]
}
],
"new": [
{
"value": "986e3f42-1797-49ae-b060-181a33b9",
"label": "Master Bedroom",
"selected": false
},
{
"value": "b4e794b2-7a5f-4567-9422-cb1c67c8",
"label": "Kitchen",
"selected": false
},
{
"value": null,
"label": "Select",
"selected": true
}
]
}
如您所见,default
和new
数组嵌套在areas
对象中。我正在尝试显示default
数组中的区域,但也可以使用new
数组中的数据/标签创建新区域。但是,我不知道Angular是否会让我重复一个我正在重复的数组之外的数组。有没有人知道更好的方法来做到这一点,或者更好的方式来安排数据?
答案 0 :(得分:0)
我并不完全明白您尝试做什么,但如果您在default
和new
数组中使用相同的索引,则可能会有类似的内容此
<div ng-repeat="item in areas.default">
{{item.value}} <!-- This is from areas.default array -->
{{areas.new[$index].value}} <!-- This is from areas.new array -->
</div>
答案 1 :(得分:0)
是的,你可以(伪):
<div ng-repeat="default in areas.default">
<div ng-repeat="new in default.new">
<div ng-repeat="obj in new">
{{ obj.value}}
</div>
</div>
</div>