dqxuiq7772 2015-03-05 09:29
浏览 34
已采纳

使用angularJs的数据表显示没有数据错误?

I want to use datatable in angularjs. I have written directives and data table initializing and displaying rows in table first time. When searching or filtering,it shows no data in table error message.

Directive code is

"use strict";
invoiceApp.directive('itemTable', function () {
return {
        restrict: 'E',
        replace: true,
        templateUrl: 'app/components/item/item_table.html',
        link: function (scope, table) {
            table.dataTable();

        }
    }
})

Template is,

<table my-table id="dt_basic" class="table table-bordered table-hover" width="100%">
<thead>                         
    <tr>
        <th class="text-center" width="10">
            <input type="checkbox" name="checkbox-inline" id="slt_all">
        </th>
        <th data-class="expand">Name</th>
        <th data-hide="phone">Description</th>
        <th data-hide="phone">Unit</th>
        <th>Rate</th>
    </tr>
</thead>
<tbody>
    <tr ng-repeat="item in items">
        <td class="text-center"><input type="checkbox" checked="checked" name="checkbox-inline"></td>
        <td>{{item.name}}</td>
        <td>{{item.description}}</td>
        <td>{{item.unit}}</td>
        <td>AED {{item.rate}}</td>
    </tr>

Controller is,

    'use strict';
    invoiceApp.controller('itemController', ['$scope', 'ItemService', function ($scope, ItemService) {
$scope.items = //datas
        }]);

enter image description here Why it happening ?

  • 写回答

2条回答 默认 最新

  • douju1968 2015-03-05 09:40
    关注

    Instead of creating new directive, simply add datatable=" using this angular datatable module

    HTML:

    <table datatable="" class="row-border hover">
        <thead>
        <tr>
            <th>ID</th>
            <th>First name</th>
            <th>Last name</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>1</td>
            <td>Foo</td>
            <td>Bar</td>
        </tr>
        <tr>
            <td>123</td>
            <td>Someone</td>
            <td>Youknow</td>
        </tr>
        <tr>
            <td>987</td>
            <td>Iamout</td>
            <td>Ofinspiration</td>
        </tr>
        </tbody>
    </table>
    

    JS :

    angular.module('showcase', ['datatables']);
    

    More detail AngularJs Datatable and Download

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题