Skip to content

Commit f741f09

Browse files
authored
Merge pull request #477 from cal-smith/issue#278
fix(pagination): make sure to convert inputs to actual numbers
2 parents 367e12e + a1e9c1b commit f741f09

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/pagination/pagination.component.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { ExperimentalService } from "./../experimental.module";
2323
*
2424
* ```typescript
2525
* selectPage(page) {
26-
* // ... your code to laod the page goes here
26+
* // ... your code to load the page goes here
2727
*
2828
* this.model.currentPage = page;
2929
*
@@ -279,7 +279,6 @@ export class Pagination {
279279
* `PaginationModel` with the information about pages you're controlling.
280280
*
281281
* @type {Model}
282-
* @memberof Pagination
283282
*/
284283
@Input() model: PaginationModel;
285284

@@ -327,32 +326,28 @@ export class Pagination {
327326
*
328327
* You should tie into this and update `model.currentPage` once the fresh
329328
* data is finally loaded.
330-
*
331-
* @memberof Pagination
332329
*/
333330
@Output() selectPage = new EventEmitter<number>();
334331

335332
get itemsPerPage() {
336333
return this.model.pageLength;
337334
}
338335
set itemsPerPage(value) {
339-
this.model.pageLength = value;
336+
this.model.pageLength = Number(value);
340337
this.currentPage = 1; // reset page
341338
}
342339

343340
get currentPage() {
344341
return this.model.currentPage;
345342
}
346343
set currentPage(value) {
344+
value = Number(value);
347345
// emits the value to allow the user to update current page
348346
// in the model once the page is loaded
349347
this.selectPage.emit(value);
350348
}
351349
/**
352350
* The last page number to display in the pagination view.
353-
*
354-
* @returns {number}
355-
* @memberof Pagination
356351
*/
357352
get lastPage(): number {
358353
const last = Math.ceil(this.model.totalDataLength / this.model.pageLength);
@@ -371,19 +366,13 @@ export class Pagination {
371366

372367
/**
373368
* The previous page number to navigate to, from the current page.
374-
*
375-
* @returns {number}
376-
* @memberof Pagination
377369
*/
378370
get previousPage(): number {
379371
return this.currentPage <= 1 ? 1 : this.currentPage - 1;
380372
}
381373

382374
/**
383375
* The next page number to navigate to, from the current page.
384-
*
385-
* @returns {number}
386-
* @memberof Pagination
387376
*/
388377
get nextPage(): number {
389378
const lastPage = this.lastPage;
@@ -412,12 +401,7 @@ export class Pagination {
412401
/**
413402
* Generates a list of numbers. (Python function)
414403
* Used to display the correct pagination controls.
415-
*
416-
* @param {number} stop
417-
* @param {number} [start=0]
418-
* @param {number} [step=1]
419404
* @returns {array}
420-
* @memberof Pagination
421405
*/
422406
range(stop: number, start = 0, step = 1) {
423407
return range(stop, start, step);

0 commit comments

Comments
 (0)