【发布时间】:2016-10-10 09:19:37
【问题描述】:
我正在尝试使用嵌套的 ng-repeat。但是,上部 ng-repeat 中的值 将作为内部 ng-repeat 中的参数传递。我正在尝试创建一个函数 返回一个数组,以便我可以在内部 ng-repeat 中使用它。但它似乎不起作用。 我怎样才能做到这一点? 这是我的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>
这是 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;
}
提前谢谢!!!
【问题讨论】:
-
请提供样本数据进行测试
-
我可以通过这个 $scope.employee = data; 看到从服务器获取的数据;这绝对是一个样本
-
我之前看过它,但是我如何构造我的控制器来获取内部 ng-repeat 的值。请我需要帮助另外,我没有使用按钮单击来获取页面上的信息加载
标签: javascript jquery angularjs json