I am working with a reactive data source in Angular-Meteor and I want to find a method to trigger the reactive function to run again after modifying another $scope value. Specifically, I aim to change the sorting order based on $scope.model.sort:
angular.module('...').controller('MyCtrl', [...], function(...){
//Subscribe
$scope.subscribe('articles');
//Initialization
$scope.model = {
sort: 1,
...
}
//Reactive definitions
$scope.helpers({
articles: () => {
console.log("+ articles");
return Articles.find({...}, {sort: {colToSort: $scope.model.sort} });
}
});
Subsequently, I update the sorting order in the HTML or by calling a function:
ng-click="model.sort=-1"
ng-click="setSort(-1)"
JS
$scope.setSort = function(sort) {
console.log("+ setResourcesSort(%s)", sort);
$scope.model.sort = sort;
}
Unfortunately, neither of these approaches appears to trigger a re-run of the reactive helper. Is there a way to force the reactive helper to rerun when the referenced $scope.model.sort
is altered?