无法从服务器响应 (WebAPI) 获取输出 (AngularJS)
Can't get an output(AngularJS) from server reponse(WebAPI)
我真的卡住了。无法理解,为什么我无法输出服务器响应。
部分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();
}
}
());
你必须分配数据,当你的承诺被解决时,它会返回到一个变量。
例如:
function FileListCtrl(fileResource, $scope){
fileResource.get().then(function(responseData) {
$scope.smallFiles = responseData.smallFiles;
$scope.averageFiles = responseData.averageFiles;
$scope.bigFiles = responseData.bigFiles;
});
}
我真的卡住了。无法理解,为什么我无法输出服务器响应。
部分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();
}
}
());
你必须分配数据,当你的承诺被解决时,它会返回到一个变量。
例如:
function FileListCtrl(fileResource, $scope){
fileResource.get().then(function(responseData) {
$scope.smallFiles = responseData.smallFiles;
$scope.averageFiles = responseData.averageFiles;
$scope.bigFiles = responseData.bigFiles;
});
}