【问题标题】:angular datatables ng-repeat doesn't work角度数据表 ng-repeat 不起作用
【发布时间】:2015-10-22 19:56:46
【问题描述】:

我正在使用angular-datatables,但是当我使用ng-repeat 时,数据表的功能不起作用(排序、搜索、计数等)

HTML:

<table  datatable=""  class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
    <tr>
        <th><input type="checkbox" id="checkall" /></th>
        <th>Navn</th>
        <th>Projekt</th>
        <th>Timer</th>
        <th>Uge</th>
        <th>Edit</th>
    </tr>
    </thead>

    <tbody ng-repeat="timesheet in timesheets">
    <tr>
        <td><input type="checkbox" class="checkthis" /></td>
        <td>{{timesheet.user}}</td>
        <td>{{timesheet.projectid}}</td>
        <td>  <standard-time-no-meridian etime='timesheet.TotalTime'></standard-time-no-meridian></td>
        <td>{{timesheet.week}}</td>
        <td><p data-placement="top" data-toggle="tooltip" title="Edit"><button class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" ><span class="glyphicon glyphicon-pencil"></span></button></p></td>
    </tr>
    </tbody>

 </table>

JavaScript:

  .controller('TimesheetMainCtrl', function ($rootScope, $scope, $timeout) {

   dpd.timesheetold.get(function (result, err) {

        if (err) return console.log(err);
       $timeout(function() {
           $scope.timesheets = result;


       })
    })

});

我尝试将 ng 添加到 datatable="" 但这只是给我一个控制台错误

TypeError:无法读取未定义的属性“serverSide” 在 Object.f [as fromOptions] (angular-datatables.min.js:6)

【问题讨论】:

  • 我认为你应该在tr 元素上使用ng-repeat="timesheet in timesheets",而不是tbody。还要设置datatable="ng",更多详情见angular way
  • 确实将其移至 tr 标签,并设置了 datatable="ng" 但这只是给了我控制台错误

标签: javascript angularjs datatables ng-repeat angular-datatables


【解决方案1】:

接缝是角度数据表中的错误 https://github.com/l-lin/angular-datatables/issues/439

将在 0.51 中修复,直到它可以运行旧版本

【讨论】:

    【解决方案2】:

    处理这个问题已经有一段时间了,问题实际上是如果我刷新包含数据表的状态的页面,它会中断。

    如果您从另一个州导航到它,它会起作用。因此,我通过在刷新页面时重定向到另一个状态来解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多