Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

page set to NaN in $pagination.limit $watch() #255

Closed
andryfailli opened this issue Jan 19, 2016 · 1 comment
Closed

page set to NaN in $pagination.limit $watch() #255

andryfailli opened this issue Jan 19, 2016 · 1 comment

Comments

@andryfailli
Copy link

If $pagination.limit changes from undefined to a number, calculating the following formula Math.floor(((self.page * oldValue - oldValue) + newValue) / (isZero(newValue) ? 1 : newValue)) will cause self.page to be set to NaN.

I've wrapped the formula in an if and it works.

$scope.$watch('$pagination.limit', function (newValue, oldValue) {
  if(newValue === oldValue) {
    return;
  }

  if(!isNaN(newValue) && !isNaN(oldValue)) {
    // find closest page from previous min
    self.page = Math.floor(((self.page * oldValue - oldValue) + newValue) / (isZero(newValue) ? 1 : newValue));
  }

  self.onPaginationChange();
});
andryfailli added a commit to andryfailli/md-data-table that referenced this issue Jan 19, 2016
@daniel-nagy
Copy link
Owner

This change has been added in v0.10.4, mdTablePagination.js:90.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants