Skip to content

Commit 10ab63d

Browse files
committed
Added forPage function and fixed documenation
1 parent b9dda71 commit 10ab63d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ and for rendering page numbers:
103103

104104
```html
105105
<span ng-repeat="n in [] | paginationRange: pg.pages">
106-
<button ng-click="pagination.toPageId(n)">{{n}}</button>
106+
<button ng-click="pg.set({start: pg.forPage(n)})">{{n}}</button>
107107
<span>
108108
```
109109

angular-pagination.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ paginationModule.factory("Pagination", function(){
111111
pagination.prototype.last = function(){
112112
return Math.floor((this.pages - 1) * this.limit)
113113
}
114+
/**
115+
* Get the starting point of a specific page
116+
* @param page
117+
* @returns {number}
118+
*/
119+
pagination.prototype.forPage = function(page){
120+
page = parseInt(page,10) || 1
121+
if(page < 1) page = 1
122+
if(page > this.pages) page = this.pages
123+
return (page - 1) * this.limit
124+
}
114125
/**
115126
* Set the properties of the pagination
116127
* @param obj

0 commit comments

Comments
 (0)