0
,所以我上AngularJS應用程序的工作,我需要使用$ HTTP服務從服務器獲取數據,就像這樣:
$http({
method: 'GET',
url: $rootScope.apiURL + 'getAllClientLocations/' + session,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function (response) {
if (response.ErrorMessage === null && response.Result !== null) {
$scope.locations = Object.keys(response.Result).map(function (key) {
return response.Result[key]
});
}
});
而且我想使用角度數據表顯示數據。數據顯示得很好,我得到了數據表控件(分頁,按鈕,搜索框),但它們都不起作用,我得到了「表中沒有數據」的圖例。
這是我的HTML設置:
<table class="table table-striped table-bordered table-hover" datatable="ng" dt-options="dtOptions">
<thead>
<tr>
<th>{{ 'BRANCH' | translate }}</th>
<th>{{ 'NAME' | translate }}</th>
<th>{{ 'STATUS' | translate }}</th>
<th>{{ 'ACTIONS' | translate }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="station in stations">
<td>{{ station.LocationName }}</td>
<td>{{ station.StationName }}</td>
<td>{{ station.StationStatus }}</td>
<td>
<button type="button" class="btn btn-primary btn-xs" ng-click="editStation(station.CliLocationSalesStationId)" ng-stow="action.edit">Update</button>
<button type="button" class="btn btn-success btn-xs" ng-if="!station.HardwareFingerprint" ng-click="authorizeStation(station.CliLocationSalesStationId)" ng-stow="action.edit">Authorize</button>
<button type="button" class="btn btn-success btn-xs" ng-if="station.HardwareFingerprint" ng-click="deauthorizeStation(station.CliLocationSalesStationId)" ng-stow="action.edit">Deauthorize</button>
</td>
</tr>
</tbody>
</table>
這些都是我dtOptions:
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withPaginationType('full_numbers')
.withDOM('frtip')
.withButtons([
'copy',
'print',
'excel'
]);
我知道有某種因不同步的問題,在DOM之前我得到的建來自服務器的數據。在我從服務器獲得成功數據後,是否有辦法告訴數據表呈現?
如果你加氣站用它的數據來自Web服務 –