【发布时间】:2017-01-07 12:53:13
【问题描述】:
您好,我有以下从服务返回的数据,我无法控制它的返回方式:
{"day_1":[{"classroom":"Nursery","count":0},{"classroom":"Junior Kindy","count":1}],"day_2":[{"classroom":"Nursery","count":4},{"classroom":"Junior Kindy","count":0}]}
但我需要以如下所示的枢轴格式显示它:
classroom | day_1 | day_2
============ ======== ======
Nursery | 0 | 4
Junior Kindy | 1 | 0
这是控制器中的代码
$scope.rolls=[];
Rolls.getRollMarked().then(
function(data){
console.log(data.data);
$scope.rolls = data.data;
}
)
在我正在使用的视图中,但它不显示当天的任何计数,我不知道如何显示它..所以请告诉我如何以上述格式显示它?
<table class="table table-bordered">
<tr>
<td>Classroom</td>
<td>day_1</td>
<td>day_2</td>
</tr>
<tr ng-repeat="roll in rolls">
<td>
{{roll[$index]['classroom']}}
</td>
<td>
{{roll.day_1}}
</td>
<td>
{{roll.day_2}}
</td>
</tr>
</table>
【问题讨论】:
-
您的 JSON 数据无效