I am trying to use nested ng-repeat. However, the values in the upper ng-repeat will be pass as a paramter in the inner ng-repeat. I am try to create a function that return an array So that I can use it in the inner ng-repeat.but it seems not working. how can I achieve this. this is my html
<table class="table table-condensed" id="paytable" ng-repeat="row in employeeInfo">
<thead>
<tr>
<td class="col-sm-3">Employee Info</td>
</tr>
</thead>
<tbody>
<tr>
<td>{{employeeInfo.name}}</td>
<td>
<ul ng-repeat="row in employeeLoans(employeeInfo)">
<li></li>
</ul>
</td>
</tr>
</tbody>
</table>
this is the angularJS
// this
$http.get('/api/PreviewEmployee').success(function (data)
{
$scope.employee = data;
$scope.Allowances = Allowance(data);
});
$scope.Allowance = function (data)
{
var result = [];
for(var i = 0 ; i < data.length ; i++)
{
result.push(data[i]);
}
console.log(result)
return result;
}
thanks in advance!!!
I have created code pen with sample data var x = $scope.employee;
var keys = Object.keys($scope.employee);
var result = [];
for (var i = 0; i < keys.length; i++) {
result.push(x[keys[i]]);
}
$scope.Allowances = result;
console.log($scope.Allowances);});
Codepen URL - http://codepen.io/nagasai/pen/EyPZjQ for reference
Hope this is helpful for you :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.