我真的卡住了。无法理解,为什么我无法输出服务器响应。
index.html代码的一部分
<table class="table" ng-controller="FileListCtrl">
<thead>
<tr>
<td>Less 10Mb</td>
<td>10Mb - 50Mb</td>
<td>More 100Mb</td>
</tr>
</thead>
<tbody>
<tr>
<td>{{smallFiles}}</td>
<td>{{averageFiles}}</td>
<td>{{bigFiles}}</td>
</tr>
</tbody>
</table>
fileListCtrl.js
(function()
{
"use strict";
angular
.module("fileManagement")
.controller("FileListCtrl",
["fileResource",
FileListCtrl]);
function FileListCtrl(fileResource){
fileResource.get();
}
}
());
答案 0 :(得分:1)
当您的承诺得到解决时,您必须分配数据,这些数据将返回到变量。
例如:
function FileListCtrl(fileResource, $scope){
fileResource.get().then(function(responseData) {
$scope.smallFiles = responseData.smallFiles;
$scope.averageFiles = responseData.averageFiles;
$scope.bigFiles = responseData.bigFiles;
});
}