如何使用ng-repeat访问当前数组之外的数组?
How can I use ng-repeat to access an array outside of the current array?
这是我使用的数据。这是三个不同的数组
"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是否会允许我对当前正在重复遍历的数组之外的数组进行重复。有没有人知道更好的方法,或者更好的排列数据的方法?
我不太明白你在做什么但如果你在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>
可以(pseudo):
<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>
相关文章:
- 如何从txt文件中获取要在javascript数组中使用的对象
- 在对象数组上使用map()检查差异
- 如何加载JSON数组以使用Angular-Translate翻译AngularJS网页
- 在多维数组中使用 IMG
- 比较数组并使用条件对数组列表进行排序
- 将代理与纯数组一起使用
- PDO fetchAll,fetch及其与解码JSON数组的使用
- PHP和Ajax在回调和返回数组中使用foreach循环
- 在使用promise数组时使用jQuery
- 在for循环中设置断点会导致在数组上使用原型时出错
- 在嵌入式PHP数组中使用JavaScript变量
- 如何在数组上使用 .each()
- 在数组中使用注释字符构建复杂字符串
- 使用 javascript 捕获数组并使用数组的值
- 将数组原型函数与非数组一起使用
- 为什么我的数组无法使用 innerhtml
- 如何在单个语句中的 $$('selector') 数组上使用 PrototypeJS .wrap()
- json 数组未使用 Javascript post 方法发布到 PHP
- 无法循环访问比较文本值的数组,使用量角器未定义的结果
- 动态结果数组需要使用 Angular JS 与不同布局的表绑定