admin管理员组文章数量:1415491
I am trying to use ng-table but stuck with ngTableParams. I keep getting the
[Error] Error: 'undefined' is not a constructor (evaluating 'new ngTableParams')
error, no matter what things I try.
The current code looks like
$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()));
}
});
The app and controller are invoked with ngTable and ngTableParams:
angular.module('MegaList', ['ui.bootstrap', 'ngTable']);
angular.module('MegaList').controller('DisplayMegaList', ['$scope', 'ngTableParams', function($scope, $http, ngTableParams) {
...
}
I think I've already tried all the ways to pose 'ngTable'
, 'ngTableParams'
and ngTableParams
keywords together, but it still just doesn't work.
What should I try then?
I am trying to use ng-table but stuck with ngTableParams. I keep getting the
[Error] Error: 'undefined' is not a constructor (evaluating 'new ngTableParams')
error, no matter what things I try.
The current code looks like
$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()));
}
});
The app and controller are invoked with ngTable and ngTableParams:
angular.module('MegaList', ['ui.bootstrap', 'ngTable']);
angular.module('MegaList').controller('DisplayMegaList', ['$scope', 'ngTableParams', function($scope, $http, ngTableParams) {
...
}
I think I've already tried all the ways to pose 'ngTable'
, 'ngTableParams'
and ngTableParams
keywords together, but it still just doesn't work.
What should I try then?
Share Improve this question edited Oct 1, 2014 at 12:43 rishat asked Sep 30, 2014 at 12:38 rishatrishat 8,3764 gold badges51 silver badges72 bronze badges3 Answers
Reset to default 3This is because you are missing parameter. All have to matched as well
angular.module('MegaList')
.controller('DisplayMegaList', ['$scope', '$http', 'ngTableParams', function($scope, $http, ngTableParams)
It looks like you create controller on a different module. Try to use MegaList.controller(...)
instead of FloristList.controller(...)
.
I had a similar problem and just copying the beforeEach
from this sample helped me:
https://docs.angularjs/guide/unit-testing
beforeEach(inject(function(_$controller_){
// The injector unwraps the underscores (_) from around the parameter names when matching
$controller = _$controller_;
}));
本文标签: javascriptError 39undefined39 is not a constructor (evaluating 39new ngTableParams39)Stack Overflow
版权声明:本文标题:javascript - Error: 'undefined' is not a constructor (evaluating 'new ngTableParams') - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745147754a2644776.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论