ng表分页不工作
ng-table pagination not working
情况如下:—输入字段,在其中输入用户名ng-model='user_name'。-一个按钮,用ng-click="queryUserLogs(user_name, $event) "—当我输入一个用户名,并点击按钮,下面的方法定义在我的控制器被调用:
// un: username
$scope.queryUserLogs = function(un, $event){
if(typeof $scope.user_name !== 'undefined'){
var transaction_id = gen_uuid();
$scope.$watch("user_name", function (newVal, oldVal) {
if($event.type === "click"){
console.log("Reloading...");
$scope.tableParams.reload();
delete $event.type;
}
});
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
}, {
total: 0,
getData: function($defer, params) {
BI.get({userName: $scope.user_name, page: params.page(), count: params.count()}, function(data) {
// set new data
$scope.basicInfos = data.results;
params.total(data.count);
$scope.showLogs = true;
$defer.resolve(data.results.slice((params.page() - 1) * params.count(), params.page() * params.count()));
});
},
$scope: { $data: {} }
});
} else {
console.log("Username is empty!");
}
}
- 对于第一个请求,该方法被正常调用,使用BI $资源转到服务器,获取数据并正确显示。一切都很好。
当我更改用户名并点击按钮时,控制台出现以下错误:
TypeError: undefined is not a function at http://localhost:8000/static/js/ng-table.min.js:414:33 at u (http://localhost:8000/static/js/angular.min.js:97:280) at http://localhost:8000/static/js/angular.min.js:98:417 at h.$eval (http://localhost:8000/static/js/angular.min.js:108:482) at h.$digest (http://localhost:8000/static/js/angular.min.js:106:62) at h.$apply (http://localhost:8000/static/js/angular.min.js:109:287) at f (http://localhost:8000/static/js/angular.min.js:71:247) at F (http://localhost:8000/static/js/angular.min.js:75:408) at XMLHttpRequest.x.onreadystatechange (http://localhost:8000/static/js/angular.min.js:76:457)
新数据实际上被成功检索,但是分页停止工作,如果第一个查询的用户名有4个页面,第二个只有一个页面,那么分页在第二个查询中保持为4个页面,反之亦然。
PS: ngTable被添加到控制器依赖项中。
您是否尝试使用#ngTasty表分页?
这样容易多了。
http://zizzamia.com/ng-tasty/directive/table相关文章:
- 我应该将哪些数据传递给 Spotify 应用程序才能使分页工作
- 数据表中的FixedHead没有'删除分页后无法工作
- HTML分页在第一页上搞砸了,之后它工作正常
- MVC Webgrid,javascript在排序和分页后停止工作
- 智能表分页链接不工作
- GridView客户端分页不工作
- Rails: Javascript不能在分页对象上工作
- 在网页网格表上进行实时搜索,分页仅在实际页面上工作
- 试着学习Angular——为什么这里的分页不能正常工作?
- carouFredSel滑块-上一页,下一页和分页不工作
- 过滤收集后,后网分页器不工作
- Will_paginate分页链接javascript不工作
- 延迟加载不工作与我的自定义分页
- 分页-不工作
- 为什么引导动态表分页不能工作
- AngularJS - ngrid不显示正确的页面大小&分页不工作
- 分页不能正常工作
- Javascript在数据表过滤或分页之后不工作
- 包含分页后,搜索功能无法工作
- Jeasyui DataGrid分页不能正常工作