Jquery 从服务器获取数据时出现Datatable错误

Jquery 从服务器获取数据时出现Datatable错误,jquery,angularjs,datatable,Jquery,Angularjs,Datatable,你好,我是新来的。我只是在html表中加入了dataTable。 但当某个时候,$http需要时间从服务器加载数据时。然后dataTable抛出了一些错误。前任。 在控制台中有一个错误。 如果你想知道问题的更多细节,请告诉我 HTML代码: <table datatable="ng" class="table dataTable" dt-options="dtOptions"> <thead> <tr> <th>A</

你好,我是新来的。我只是在html表中加入了dataTable。 但当某个时候,$http需要时间从服务器加载数据时。然后dataTable抛出了一些错误。前任。 在控制台中有一个错误。 如果你想知道问题的更多细节,请告诉我

HTML代码:

<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) {

    });
  };
}]);

请共享您的代码。已用一段代码更新。您必须使用
$watchCollection
。您的
$http
是异步的,因此您的DOM将加载$http捕获。这就是为什么会出现错误
$watchCollection
您的
$scope.listData
会更新视图。我从不使用$watchCollection:o。你能检查并修改我的代码吗?转到错误
https://datatables.net/manual/tech-notes/4