diff --git a/modules/Paginator.js b/modules/Paginator.js index a712c64..29d3f9e 100644 --- a/modules/Paginator.js +++ b/modules/Paginator.js @@ -44,9 +44,9 @@ angular.module('App').factory('Paginator', function($q){ } more() { - this.loading = true; - if (this.hasMore) { + this.loading = true; + return this.paginate(this.options).then((response) => { //If the results are less than the required limit then the results are finished if(response.data.results.length < self.options.limit){ @@ -54,9 +54,8 @@ angular.module('App').factory('Paginator', function($q){ } this.items = this.items.concat(response.data.results); this.options.offset = this.items.length; - this.loading = false; return this.items; - }); + }).finally(() => this.loading = false); } else { return $q.when(this.items); }