我的页面上有分页(单个页面中有 5 行) 当首先更改页码时,它会暂时变成 10 行,然后显示接下来的 5 行。
我想改善用户体验,当他改变页码时,他不会有任何UI干扰的感觉。
这是我的分页代码。
$scope.currentPage = cPage
, $scope.numPerPage = PerPage
, $scope.maxSize = maxNavSize;
$scope.numPages = function () {
return Math.ceil(dataLength / $scope.numPerPage);
};
if (watchFun)
watchFun()
watchFun = $scope.$watch('currentPage + numPerPage', function (newValue, oldValue) {
$scope.cPage = $scope.currentPage;
var begin = (($scope.currentPage - 1) * $scope.numPerPage),
end = begin + $scope.numPerPage;
// ajax call to get data for each page
$http({
url: url+ '?'+data + "&offset=" + begin + "&limit=" + PerPage,
method: "GET",
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}) .success(function (response) {
if (response.length != 0) {
$scope.historyContest =[];
$scope.historyContest = response;
}
});
});
$scope.historyContest 代表 ng-repeat,因此每个页面都会发生变化。
如果你们有任何疑问,请告诉我,我会更新它。
谢谢
最佳答案
这能解决您的问题吗?
if (response.length != 0) {
$scope.historyContest =[];
$timeout(function(){
$scope.historyContest = response;
},100);
}
关于javascript - Angularjs - 在导航中 ng-repeat 在渲染期间显示更多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35764950/