2015-07-21 56 views
1

我用angular datatables with fixed column,用于查看下面的我的HTML代码:角数据表固定列不确定是不是一个函数

<div class="row" ng-controller="PerformanceCtrl"> 
    <table id="example" datatable="" 
      class="stripe row-border order-column" 
      dt-options="dtOptions"> 
     <thead> 
      <tr> 
       <th>First name</th> 
       <th>Last name</th> 

      </tr> 
     </thead> 
     <tbody> 
     <tr> 
      <td>Tiger</td> 
      <td>Nixon</td> 
     </tr> 
    </tbody> 
</table> 

我的控制器代码如下所示:

'use strict'; 

app.controller('PerformanceCtrl', ['$scope', 'DTOptionsBuilder', 'DTColumnDefBuilder', function ($scope, DTOptionsBuilder, DTColumnDefBuilder) { 

$scope.dtOptions = DTOptionsBuilder.newOptions() 
    .withOption('scrollY', '300px') 
    .withOption('scrollX', '100%') 
    .withOption('scrollCollapse', true) 
    .withOption('paging', false) 
    .withFixedColumns({ 
     leftColumns: 1 
    }); 

}]); 

而对于我index.html文件,我按照以下顺序包括数据表库:

<script src="bower_components/jquery/dist/jquery.min.js"></script> 
<script src="bower_components/angular/angular.js"></script> 
<script src="modules/performance/controller.js"></script> 
<link rel="stylesheet" href="bower_components/angular-datatables/dist/plugins/bootstrap/datatables.bootstrap.css"> 
<script src="bower_components/DataTables/media/js/jquery.dataTables.js"></script> 
<script src="bower_components/angular-datatables/dist/angular-datatables.min.js"></script> 
<script src="bower_components/angular-datatables/dist/plugins/fixedheader/angular-datatables.fixedheader.min.js"></script> 
<script src="bower_components/angular-datatables/dist/plugins/fixedcolumns/angular-datatables.fixedcolumns.min.js"></script> 

<link rel="stylesheet" type="text/css" href="bower_components/DataTables/media/css/jquery.dataTables.min.css"> 

而且这是我的模块:

var app = angular.module('MyApp', ['datatables', 'datatables.fixedcolumns']); 

但我得到这个错误undefined is not a function为这一形象:

Undefined is not a function

如果我从表中,没有错误的选项去掉下面的代码,但没有fixedColumns:

.withFixedColumns({ 
     leftColumns: 1 
    }); 

我需要修正我的第一列,我该如何解决这个错误?

+0

请检查此; ine'angular.module('showcase.withFixedColumns',['datatables','datatables.fixedcolumns'])''。你有注入这个'datatables.fixedcolumns''吗? –

+0

@RameshRajendran是的,我注入了它,我在问题 –

+0

中添加我的模块我想我已经通过我的答案来处理您的问题。请让我知道,如果你有疑问 –

回答

2

我张贴在github这个问题,并在其上1-霖的答案。

我错过了包括下列内容:

<script src="vendor/FixedColumns-3.0.4/js/dataTables.fixedColumns.min.js"></script> 
<link rel="stylesheet" type="text/css" href="vendor/FixedColumns-3.0.4/css/dataTables.fixedColumns.min.css"> 

我应该下载FixColumns jQuery的。

1

您只是忘了将ng属性添加到数据表中。

下面正在截屏...

enter image description here

点击here for Live Demo

+0

演示链接不与我合作,并且我添加了'ng'属性,并且'ng-repeat'与示例数组一起得到了同样的错误 –

相关问题