daniel-nagy / md-data-table

Material Design Data Table for Angular Material
MIT License
1.9k stars 520 forks source link

md-on-paginate fires multiple times #604

Open mwj-1992 opened 7 years ago

mwj-1992 commented 7 years ago

when i'm using md-on-paginate and it's run multiple times Here is my code :+1: `

in controller: $socpe.paginate= function (page){ //assume page is 4 console.log('page'+page); }` the result is page 4 page 4 page 4 page 4 page 4 page 4

ghost commented 7 years ago

Try to replace with $scope.watch Delete md-on-paginate Then in controller:

var bookmark;
self.query = {
      'page': 1
    };
$scope.$watch(angular.bind(this, function () {
      return this.query;
    }), function (newValue, oldValue) {
      if(!oldValue) {
        bookmark = self.query.page;
      }

      if(!newValue) {
        self.query.page = bookmark;
      }

      getDate();
    }, true);