我正在使用角度数据表构建报告。当我执行我的页面时,我的angular.js文件中出现错误,指出undefined不是一个函数以及其他一些代码:
TypeError: undefined is not a function
at Object._showLoading [as showLoading] (http://localhost:55823/Scripts/angular-datatables/angular-datatables.renderer.js:8:23)
at showLoading (http://localhost:55823/Scripts/angular-datatables/angular-datatables.directive.js:25:39)
at postLink (http://localhost:55823/Scripts/angular-datatables/angular-datatables.directive.js:17:26)
at http://localhost:55823/Scripts/angular-1.2.19/angular.js:7050:44
at nodeLinkFn (http://localhost:55823/Scripts/angular-1.2.19/angular.js:6648:13)
at compositeLinkFn (http://localhost:55823/Scripts/angular-1.2.19/angular.js:6039:13)
at nodeLinkFn (http://localhost:55823/Scripts/angular-1.2.19/angular.js:6642:24)
at compositeLinkFn (http://localhost:55823/Scripts/angular-1.2.19/angular.js:6039:13)
at compositeLinkFn (http://localhost:55823/Scripts/angular-1.2.19/angular.js:6042:13)
at compositeLinkFn (http://localhost:55823/Scripts/angular-1.2.19/angular.js:6042:13) <table datatable="" dt-options="dtOptions" dt-columns="dtColumns" class="row-border hover datatable ng-isolate-scope">
这是构建我的桌子的角度函数:
var manageBackOrdersApp = angular.module('manageBackOrdersApp', ['sharedApp', 'datatables']);
(function () {
var manageBackOrdersController = function ($scope, $http, DTOptionsBuilder, DTColumnBuilder) {
$scope.dtOptions = DTOptionsBuilder.fromSource('/Customer/ManageBackOrders/firstJson')
.withPaginationType('full_numbers').withDisplayLength('1000');
$scope.dtColumns = [
DTColumnBuilder.newColumn('CustID').withTitle('Cust ID')
.renderWith(function(data, type, full, meta) {
return '<a target="_blank" href="gmail.com">' + full.CustID + '</a>'
}),
DTColumnBuilder.newColumn('SOID').withTitle('SO ID')
.renderWith(function(data, type, full, meta) {
return '<a target="_blank" href="gmail.com">' + full.SOID + '</a>'
}),
DTColumnBuilder.newColumn('CreateDate').withTitle('SO Date'),
DTColumnBuilder.newColumn('SPerName').withTitle('Sales Rep'),
DTColumnBuilder.newColumn('ItemID').withTitle('Item')
.renderWith(function (data, type, full, meta) {
return '<a target="_blank" href="gmail.com">' + full.ItemID + '</a>'
}),
DTColumnBuilder.newColumn('CurWhseID').withTitle('Cur Whse'),
DTColumnBuilder.newColumn('QtyOnBO').withTitle('QtyOnBO'),
DTColumnBuilder.newColumn('WhseID').withTitle('Avail Whse'),
DTColumnBuilder.newColumn('QtyAvail').withTitle('Qty Avail'),
DTColumnBuilder.newColumn('ShipMethDesc').withTitle('Ship Via'),
DTColumnBuilder.newColumn('HoldReason').withTitle('Comments')
];
}
manageBackOrdersController.$inject = ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder'];
angular.module('manageBackOrdersApp').controller('manageBackOrdersController', manageBackOrdersController)
}());
最后,这是我的HTML:
<div ng-controller="manageBackOrdersController">
<div class="dataTable_top">
<br class="clearit" />
</div>
<table datatable="" dt-options="dtOptions" dt-columns="dtColumns" class="row-border hover datatable"></table>
</div>
我不确定我是否遗漏了某些东西或者有什么不合时宜的东西。据我所知,我拥有数据表工作所需的所有包含。当我运行我的页面时,数据表加载足以显示加载部分,然后出错。谢谢。
答案 0 :(得分:6)
我猜你正在使用v0.1.1。
我认为问题来自于Angular不使用jQuery而是使用jqlite。 您需要首先包含jQuery和数据表,然后是Angular,最后是angular-datatables:
<script src="jquery.min.js"></script>
<script src="jquery.dataTables.min.js"></script>
<script src="angular.min.js"></script>
<script src="angular-datatables.min.js"></script>