【发布时间】:2016-10-07 05:45:58
【问题描述】:
我想在同一个 ng-repeat 中获取两个对象的值
$http.get('/api/PreviewPayroll').success(function (data){
//alert(data[0].empID);
$scope.allowance = data;
});
$http.get('/api/Deduction').success(function (data){
//alert(data[0].empID);
$scope.Deduction = data;
});
<tr ng-repeat="item in allowance && ng-repeat="value in Deduction">
<td>{{ item.empID }}</td>
<td>{{ value.empID }}</td>
</tr>
如何在同一个 ng-repeat 上获得两个范围对象
【问题讨论】:
-
如果你想重复两个列表,那么将列表合并为一个!将类似于
[ { deduction: ...., allowance: .... }, .... ]然后ng-repeat="item in list"然后item.deduction.empID或item.allowance.empID -
请注意,标题具有误导性。这些是 2 个
$http请求而不是 2 个控制器 -
使用来自 angularJS 的那些获取请求如何使它们成为对象数组
标签: javascript jquery angularjs asp.net-web-api