Reputation: 2597
{
"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",
}
]
}
],
}
I have this type of object. I assigned this into vm.employess
variable in controller. Now I want to repeat this in the HTML area. I managed to do this:
<div ng-repeat="i in vm.employees">
{{i.id}}
{{i.name}}
</div>
I want to repeat salary as well but I was unable to do that. Can anyone help me on that!
Upvotes: 4
Views: 67
Reputation: 6638
As you've nested json, you need to use 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>
Upvotes: 1