Skip to content
Snippets Groups Projects
Commit 829874b3 authored by Eike Cochu's avatar Eike Cochu
Browse files

updated pagination, will reload based on watcher instead of search

parent 2848ca63
No related branches found
No related tags found
No related merge requests found
<nav ng-show="total > limit"> <nav ng-show="total > limit">
<ul class="pagination"> <ul class="pagination">
<li ng-class="{disabled:page==1}"> <li ng-class="{disabled:page==1}">
<a ui-sref="{page:page==2?null:page-1}" ng-show="page>1">&laquo;</a> <a ui-sref="{page:page==2?null:page-1}" ng-show="page>1" ng-click="changePage(page-1)">&laquo;</a>
<span ng-hide="page>1">&laquo;</span> <span ng-hide="page>1">&laquo;</span>
</li> </li>
<li ng-class="{active:p==page}" ng-repeat="p in pages"> <li ng-class="{active:p==page}" ng-repeat="p in pages">
<a ui-sref="{page:p===1?null:p}" ng-bind="p"></a> <a ui-sref="{page:p===1?null:p}" ng-bind="p" ng-click="changePage(p)"></a>
</li> </li>
<li ng-class="{disabled:page>=maxPage}"> <li ng-class="{disabled:page>=maxPage}">
<a ui-sref="{page:page+1}" ng-show="page<maxPage">&raquo;</a> <a ui-sref="{page:page+1}" ng-show="page<maxPage" ng-click="changePage(page+1)">&raquo;</a>
<span ng-hide="page<maxPage">&raquo;</span> <span ng-hide="page<maxPage">&raquo;</span>
</li> </li>
</ul> </ul>
......
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
$stateProvider.state('articles.index', { $stateProvider.state('articles.index', {
url: '?page', url: '?page',
templateUrl: tplBase + '/articles/index.html', templateUrl: tplBase + '/articles/index.html',
controller: 'ArticlesIndexController' controller: 'ArticlesIndexController',
reloadOnSearch: false
}); });
$stateProvider.state('articles.show', { $stateProvider.state('articles.show', {
...@@ -68,7 +69,8 @@ ...@@ -68,7 +69,8 @@
$stateProvider.state('topics.index', { $stateProvider.state('topics.index', {
url: '?page', url: '?page',
templateUrl: tplBase + '/topics/index.html', templateUrl: tplBase + '/topics/index.html',
controller: 'TopicsIndexController' controller: 'TopicsIndexController',
reloadOnSearch: false
}); });
$stateProvider.state('topics.show', { $stateProvider.state('topics.show', {
...@@ -88,7 +90,8 @@ ...@@ -88,7 +90,8 @@
$stateProvider.state('words.index', { $stateProvider.state('words.index', {
url: '?page', url: '?page',
templateUrl: tplBase + '/words/index.html', templateUrl: tplBase + '/words/index.html',
controller: 'WordsIndexController' controller: 'WordsIndexController',
reloadOnSearch: false
}); });
$stateProvider.state('words.show', { $stateProvider.state('words.show', {
......
...@@ -79,13 +79,19 @@ ...@@ -79,13 +79,19 @@
$scope.page = Math.max($stateParams.page || 1, 1); $scope.page = Math.max($stateParams.page || 1, 1);
$scope.limit = pageSize; $scope.limit = pageSize;
ArticleFactory.query({ var loadedOnce = false;
skip: ($scope.page-1)*pageSize, $scope.$watch('page', function(newVal, oldVal) {
limit: pageSize if(newVal != oldVal || !loadedOnce) {
}, function(response) { loadedOnce = true;
$scope.articles = response.data; ArticleFactory.query({
$scope.articlesMeta = response.meta; skip: ($scope.page-1)*pageSize,
$scope.queryTime = response.$queryTime; limit: pageSize
}, function(response) {
$scope.articles = response.data;
$scope.articlesMeta = response.meta;
$scope.queryTime = response.$queryTime;
});
}
}); });
}]); }]);
...@@ -214,6 +220,9 @@ ...@@ -214,6 +220,9 @@
$scope.calculatePages(); $scope.calculatePages();
$scope.changePage = function(page) {
$scope.page = page;
};
}]); }]);
})(); })();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment