ng-table 排序和过滤功能和分页功能都不能用,点击执行了getData()函数ui没反应
ng-table 排序和过滤功能和分页功能都不能用,点击执行了getData()函数ui没反应
下面是代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular.js"></script>
<!--<script src="ang.js"></script>-->
<link rel="stylesheet" ; href="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.css">
<script src="https://unpkg.com/ng-table@2.0.2/bundles/ng-table.min.js"></script>
<!--<script src="ng-table.min.js"></script>-->
<div ng-app="myApp" ng-controller="myCtrl">
<table show-filter="true" ng-table="tableParams" class="table table-striped table-bordered table-hover table-condensed">
<tr ng-repeat="user in $data">
<td title="'名称'" filter="{ name: 'text'}" sortable="'name'">
{{user.name}}</td>
<td title="'年龄'" filter="{ age: 'number'}" sortable="'age'">
{{user.age}}</td>
</tr>
</table>
</div>
<script>
var app = angular.module("myApp", ["ngTable"]);
app.controller('myCtrl',
function($scope, NgTableParams) {
var pa = {
page: 1,
count: 2
};
$scope.tableParams = new NgTableParams(pa, {
counts: [],
getData: function(params) {
var data = [{ name: "Moroni", age: 50 }, { name: "222", age: 10 }, { name: "333", age: 40 }, { name: "474", age: 25 }];
var page = params.page();
var size = params.count();
$scope.data = angular.copy(data);
params.total(data.length);
console.log(params);
return data;
}
});
})
</script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论