我正在使用ng-Table of AngularJS在我的应用程序中进行搜索,排序和分页。搜索后我想将tableParams
的页面参数值重置为1.我怎样才能实现相同的目标?
$scope.$watch("filter.$", function() {
$scope.tableParams.reload();
$scope.caseWOTableParams.reload();
});
$scope.tableParams = new ngTableParams({
page: 1 , // show first page
count: 10, // count per page
sorting: {
name: "desc"
} //Initial sorting.
//filter: $scope.filter //filter
}, {
total: $scope.completedQueries.length, // length of data
getData: function($defer, params) {
var filteredData = $filter('filter')(newWorkOrder, $scope.filter);
}
var orderedData = params.sorting() ?
$filter('orderBy')(filteredData, params.orderBy()) : filteredData;
//orderedData = $filter('filter')(orderedData, params.filter());
params.total(orderedData.length);
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
//filterOptions: $scope.filterOptions;
},
$scope: $scope
}
);
答案 0 :(得分:1)
我只需要传递如下所述的参数:
$scope.$watch("filter.$", function()
{
$scope.tableParams.reload();
$scope.caseWOTableParams.reload();
$scope.tableParams.page(1);//reset page to 1 after filter.
});