Hi there,
I’m using netanelgilad:ng-infinite-scroll
for a project and is working as expected except for the reactivity.
Has anyone managed to make a controller to implement this in a reactive way?
To give you an idea, this controller has a part with:
$scope.reset = function () { $scope.items = []; $scope.page = 0; $scope.isLoadingItems = false; };
and the load more method:
` $scope.addMoreItems = function () {
if ($scope.isLoadingItems) return;
$scope.isLoadingItems = true;
const bunch = Items.find({}, {
limit: Meteor.settings.public.perPage
, skip: (($scope.page - 1) * Meteor.settings.public.perPage)
}).fetch();
bunch.forEach( function (each) {
if( !_($scope.items).find(function (maybeAdded){ return each._id === maybeAdded._id })) {
// Add if absent
$scope.items.push(each);
}
});
$scope.isLoadingItems = false;
$scope.page += 1;
};`
the reactivity is lost because $scope.items
is just an array. Do you know if would it help if I make it anything else? would a meteor collection be overkill or help?