Ng-repeat with arrays

{
"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 to a variable vm.employessin the controller. Now I want to repeat this in the field of HTML. I managed to do this:

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

I want to repeat the salary, but I could not do it. Can someone help me with this?

+4
source share
1 answer

How you 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>
+1
source

Source: https://habr.com/ru/post/1656070/


All Articles