您好我是角度JS的新手。我只是参与了html表中的dataTable。 但有时 $ http 需要时间从服务器加载数据。然后dataTable抛出一些错误。恩。 alert screenshot 并在控制台中出现错误console screenshot。 如果您想了解问题的其他详细信息,请告诉我?
HTML code:
<table datatable="ng" class="table dataTable" dt-options="dtOptions">
<thead>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
<th>F</th>
<th>G</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="data in list">
<td>
{{data.A}}
</td>
<td>
{{data.B}}
</td>
<td>
{{data.C}}
</td>
<td>
{{data.D}}
</td>
<td>
{{data.E}}
</td>
<td>
{{data.F}}
</td>
<td>
{{data.G}}
</td>
</tr>
</tbody>
控制器代码:
app.controller('AController', ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder', function($scope, $http, DTOptionsBuilder, DTColumnBuilder) {
// DataTables configurable options
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withDisplayLength(10)
.withLanguage({
"sEmptyTable": "No record found",
});
$scope.listData = function() {
$http({
url: Api_url,
method: 'GET',
data: {},
headers: $rootScope.headers
}).success(function(data, status, headers, config) {
$scope.list = data.Params;
}).error(function(data, status, headers, config) {
});
};
}]);