gpt4 book ai didi

javascript - ng-repeat 数组

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:27:35 25 4
gpt4 key购买 nike

{
"employees" : [
{
"name" : "XXX",
"id" : "1",
"Salary" : [
{
"Month" : "XXXX",
"Amount" : "XXXX",
},
{
"Month" : "XXXX",
"Amount" : "XXXX",
},
{
"Month" : "XXXX",
"Amount" : "XXXX",
}
]
},
{
"name" : "YYY",
"id" : "2",
"Salary" : [
{
"Month" : "YYYY",
"Amount" : "YYYY",
},
{
"Month" : "YYYY",
"Amount" : "YYYY",
},
{
"Month" : "YYYY",
"Amount" : "YYYY",
}
]
}
],
}

我有这种类型的对象。我将其分配给 Controller 中的 vm.employess 变量。现在我想在 HTML 区域重复这个。我设法做到了这一点:

 <div ng-repeat="i in vm.employees">
{{i.id}}
{{i.name}}
</div>

我也想重复薪水,但我做不到。谁能帮我解决这个问题!

最佳答案

因为你已经嵌套了json,你需要使用nested ng-repeat

<div ng-repeat="i in vm.employees">
{{i.id}}
{{i.name}}
<div ng-repeat="sal in i.Salary">
{{sal.Month}}
{{sal.Amount}}
</div>
</div>

关于javascript - ng-repeat 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39744241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com