Last active
August 29, 2015 13:57
-
-
Save maxx-coffee/9655849 to your computer and use it in GitHub Desktop.
will_paginate with angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.buildPagination = () -> | |
c = $scope.current_page | |
padded = $scope.pagination_padding*2 | |
arr = [] | |
if c <= $scope.total_pages | |
min = c - $scope.pagination_padding | |
max = c + $scope.pagination_padding | |
show_next = true | |
show_prev = true | |
if min <= 0 | |
min = 1 | |
max = if padded > $scope.total_pages then $scope.total_pages else padded | |
else if $scope.total_pages < padded | |
min = 1 | |
max = $scope.total_pages | |
else if max > $scope.total_pages | |
min = $scope.total_pages - padded | |
max = $scope.total_pages | |
show_next = if (c < $scope.total_pages) then true else false | |
show_prev = if (c > 1) then true else false | |
while min <= max | |
arr.push(min) | |
min++ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment