我正在尝试使用ng-table但被ngTableParams所卡住。我一直在
[Error] Error: 'undefined' is not a constructor (evaluating 'new ngTableParams')
错误,无论我尝试什么。
当前代码看起来像
$scope.tableParams = new ngTableParams({
page: 1,
count: 200,
sorting: {
name: 'asc'
}
}, {
groupBy: 'area',
total: TheData.length,
getData: function($defer, params) {
// use build-in angular filter
var orderedData = params.sorting() ? $filter('orderBy')(TheData, params.orderBy()) : TheData;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
应用和控制器通过ngTable和ngTableParams调用:
angular.module('MegaList', ['ui.bootstrap', 'ngTable']);
angular.module('MegaList').controller('DisplayMegaList', ['$scope', 'ngTableParams', function($scope, $http, ngTableParams) {
...
}
我想我已经尝试了所有方法来一起组合
'ngTable'
,'ngTableParams'
和ngTableParams
关键字,但是仍然不起作用。那我该怎么办?
最佳答案
这是因为缺少参数。所有都必须匹配
angular.module('MegaList')
.controller('DisplayMegaList', ['$scope', '$http', 'ngTableParams', function($scope, $http, ngTableParams)