Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
paginated developer pages and added them to browser history (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessamarie authored Sep 28, 2016
1 parent 5b7d4f2 commit c69faaf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 14 additions & 2 deletions client/app/user/user.controller.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict';

angular.module('observatory3App')
.controller('UserCtrl', function ($scope, $stateParams, $location, User) {
.controller('UserCtrl', function ($scope, $stateParams, $location, $rootScope, User) {
$scope.currentUsers = User.query();
$scope.pastUsers = User.past();
$scope.users = $scope.currentUsers;
$scope.searchString = {name:""};
$scope.currentPage = 0;
$scope.defaultPageSize = 48;
if ($stateParams.page) {
$scope.currentPage = parseInt($stateParams.page);
}
$scope.defaultPageSize = 36;
$scope.pageSize = $scope.defaultPageSize;

$scope.past = false;
Expand All @@ -27,12 +30,14 @@ angular.module('observatory3App')
$scope.increment = function(){
if ($scope.currentPage < $scope.numberOfPages()-1){
$scope.currentPage += 1;
$location.search("page", $scope.currentPage);
}
};

$scope.decrement = function(){
if ($scope.currentPage > 0){
$scope.currentPage -= 1;
$location.search("page", $scope.currentPage);
}
};

Expand All @@ -56,6 +61,13 @@ angular.module('observatory3App')
}
$scope.currentPage = 0;
};

$rootScope.$on('$locationChangeEnd', function() {
if ($stateParams.page) {
$scope.currentPage = parseInt($stateParams.page);
}
})

})
.filter('startFrom', function() {
return function(input, start) {
Expand Down
5 changes: 3 additions & 2 deletions client/app/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ angular.module('observatory3App')
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('user', {
url: '/users/:state',
url: '/users/:state?page',
templateUrl: 'app/user/user.html',
controller: 'UserCtrl'
controller: 'UserCtrl',
reloadOnSearch: false
});

// If the user navigates to /me, redirect them to their profile page
Expand Down

0 comments on commit c69faaf

Please sign in to comment.