@@ -80,6 +80,7 @@ export class PaginationComponent implements DoCheck, OnInit {
8080 } else {
8181 this . config = cloneDeep ( this . defaultConfig ) ;
8282 }
83+ this . lastPageNumber = this . getLastPageNumber ( ) ;
8384 this . pageNumber = this . config . pageNumber ;
8485 this . prevConfig = cloneDeep ( this . config ) ;
8586 }
@@ -157,7 +158,7 @@ export class PaginationComponent implements DoCheck, OnInit {
157158 * Start Index of Current Page
158159 */
159160 getStartIndex ( ) : number {
160- return this . config . totalItems ? this . config . pageSize * ( this . config . pageNumber - 1 ) + 1 : 0 ;
161+ return ( this . config . totalItems !== undefined ) ? this . config . pageSize * ( this . config . pageNumber - 1 ) + 1 : 0 ;
161162 }
162163
163164 /**
@@ -167,7 +168,7 @@ export class PaginationComponent implements DoCheck, OnInit {
167168 let numFullPages = Math . floor ( this . config . totalItems / this . config . pageSize ) ;
168169 let numItemsOnLastPage = this . config . totalItems - ( numFullPages * this . config . pageSize ) || this . config . pageSize ;
169170 let numItemsOnPage = this . isLastPage ( ) ? numItemsOnLastPage : this . config . pageSize ;
170- return this . config . totalItems ? this . getStartIndex ( ) + numItemsOnPage - 1 : 0 ;
171+ return ( this . config . totalItems !== undefined ) ? this . getStartIndex ( ) + numItemsOnPage - 1 : 0 ;
171172 }
172173
173174 /**
@@ -235,7 +236,7 @@ export class PaginationComponent implements DoCheck, OnInit {
235236 * Check if current Page is Last Page
236237 */
237238 private isLastPage ( ) : boolean {
238- return this . config . pageNumber === this . lastPageNumber ;
239+ return ( this . config . pageNumber === this . lastPageNumber ) ;
239240 }
240241}
241242
0 commit comments