How to retrieve data from the nested json object using ng-repeat

advertisements

I'm trying to retrieve the EmpName from the below mentioned JSON object using ng-repeat.

My js file:

$scope.items = [];
        $scope.allItems = [{

        "categoryId": 1,
        "categoryName": "abc",
        "Employee": [{
            "EmpId": 1,
            "EmpName": "Raj",
            "EmpJob": "Accounts",
            "DataList": [{
                "year": "Oct-2015",
                "salary": "244"
            },
            {
                "year": "Jul-2015",
                "salary": "100"
            },
            {
                "year": "Jun-2015",
                "salary": "117"
            }]
        }]
    },
    {
        "categoryId": 2,
        "categoryName": "xyz",
        "Employee": [{
            "EmpId": 2,
            "EmpNameName": "Sita",
            "EmpJob": "Software Engineer",
            "DataList": [{
                "year": "Oct-2015",
                "salary": "244"
            },
            {
                "year": "Jul-2015",
                "salary": "100"
            },
            {
                "year": "Jun-2015",
                "salary": "117"
            }]
        }]
    }]
}]

My html:

<div id="Div1" ng-repeat="item in allItems">
  <div id="Div2" >
     <div id="Div3">
       <font color="white">{{item.EmpName}}</font>
     </div>
  </div>
</div>

Here I'm pushing allItems into items array.Then how can I retrieve EmpName from items array.Can anyone please help me out regarding this issue ...


YOu can do something like Every item contains Employee Array with only one Employee object. So you can get first item from Employee list and then get it's EmplyeeName

 <div id="Div1" ng-repeat="item in items" >
     <div id="Div2" >
          <div id="Div3"><font color="white">{{item.Employee[0].EmpName}}</font>                  </div>
  </div>