self loadMore function return self object promise then function return

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
self.loadMore = function() {
return self.object.$promise.then(function() {
return resource.getFeed({id: self.object.id, page: self.page + 1},
function (newObjects, headers) {
self.page += 1;
Array.prototype.push.apply(self.feed, newObjects);
self.hasMorePages = self.feed.length < headers('Count');
},
function() {
self.hasMorePages = false;
}
).$promise;
});
};