我正在尝试使用 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()));
}
});
应用程序和 Controller 使用 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)
关于javascript - 错误 : 'undefined' is not a constructor (evaluating 'new ngTableParams' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26121115/