Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 数据表在angular.js中不工作_Javascript_Jquery_Angularjs_Datatables - Fatal编程技术网

Javascript 数据表在angular.js中不工作

Javascript 数据表在angular.js中不工作,javascript,jquery,angularjs,datatables,Javascript,Jquery,Angularjs,Datatables,我试图在my表中应用dataTabe,但没有得到正确的数据表 我首先在角度表中填充数据,我应用dataTable,没有dataTable,我得到正确的结果 我的控制器: MyService.getData(function (response) { if (response.data.success) { $scope.items = angular.copy(response.data); $timeout(function () {

我试图在my表中应用dataTabe,但没有得到正确的数据表

我首先在角度表中填充数据,我应用dataTable,没有dataTable,我得到正确的结果

我的控制器:

 MyService.getData(function (response) {
    if (response.data.success) {
        $scope.items = angular.copy(response.data);
            $timeout(function () {
                var table = $("#test").dataTable();
            }, 200)

    } else {
        $scope.items = [];
    }
});
HTML:


身份证件
组名
创建日期
更新日期
{{item.userGroupId}
{{item.groupName}
{{item.createdDate}
{{item.updateDate}
截图:

在应用DataTable之前:

应用dataTable后:


我已经在DATABATE DOC和谷歌中搜索过,但是我没有发现任何线索。请帮助我。

你应该真正考虑使用角度数据(可包含在指令、服务和工厂中的数据)。我很乐意做一个演示。@davidkonrad嘿,我到处都在使用jquery数据表,它在其他屏幕上运行良好。只有在一个屏幕上,我得到这个问题的一个问题,我不能改变任何地方。好吧,你使用它不正确,有一个角度模块已经为这个插件可用。为什么要重新发明轮子?您可以直接将数据传递到插件并进行初始化,而无需使用
ng repeat
。你目前所做的只是猜测你需要200毫秒的等待时间,这并不稳定。你应该在指令中这样做。让插件构建html也将更有效率anyway@charlietfl,确切地说-OP不必在任何地方都使用angular数据表,只是在存在竞争条件的情况下(或者类似情况,问题有点模糊)-因为angular模块共享相同的CSS和数据表代码,外表上应该没有差别。
<table id="test">
    <thead>
        <tr>
            <th style="width: 10%">Id</th>
            <th style="width: 20%">Group Name</th>
            <th style="width: 20%">Created Date</th>
            <th style="width: 20%">Updated Date</th>
        </tr>
    </thead>

    <tbody ng-repeat="item in items">
        <tr>
            <td>{{item.userGroupId}}</td>
            <td>{{item.groupName}}</td>
            <td>{{item.createdDate}}</td>
            <td>{{item.updatedDate}}</td>
        </tr>
    </tbody>
</table>