Skip to content

Commit 7f9cef4

Browse files
committed
Fix sorting option in pagination
1 parent 094e26f commit 7f9cef4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/angular-meteor-collections.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ angularMeteorCollections.factory('$collection', ['$q', 'HashKeyCopier', '$subscr
6363
limit: parseInt(scope.perPage),
6464
skip: (parseInt(scope.page) - 1) * parseInt(scope.perPage)
6565
};
66-
if (scope.sort) { options.sort = [scope.sort]; }
66+
if (scope.sort) { options.sort = scope.sort; }
6767
}
6868

6969
var ngCollection = new AngularMeteorCollection(collection, $q, selector, options);
@@ -98,11 +98,12 @@ angularMeteorCollections.factory('$collection', ['$q', 'HashKeyCopier', '$subscr
9898
rebind();
9999

100100
if (paginate){
101-
scope.$watch("page", function(newValue, oldValue){
102-
if (!newValue)
101+
scope.$watchGroup(['page', 'sort'], function(newValues, oldValues){
102+
if (!newValues)
103103
return;
104104

105-
if (newValue == oldValue)
105+
if (newValues[0] == oldValues[0] &&
106+
newValues[1] == oldValues[1])
106107
return;
107108

108109
if (unregisterWatch)

0 commit comments

Comments
 (0)