I'm following the Firebase-util Paginate Infinite Scroll demo, and was wondering if there is a way to load an initial number of items, instead of loading 0 items to begin with.
When I click on my button, I'm loading in the next 16 items. Is there a way I can load 16 items on the initial load, and then another 16 upon clicking my button, etc etc?
My HTML and JS looks like this:
index.html
<h3>Items loaded: {{scrollItems.length}}</h3>
<button ng-click="scrollItems.scroll.next(16)">Load Next 16</button>
app.js
app.controller('ServiceListController', ['$scope', '$firebaseArray', '$scrollArray',
function($scope, $firebaseArray, $scrollArray) {
var servicesRef = new Firebase('https://fbutil.firebaseio.com/paginate');
$scope.scrollItems = $scrollArray(servicesRef, 'number');
}])
app.factory('$scrollArray', ['$firebaseArray', function($firebaseArray) {
return function(ref, field) {
var scrollRef = new Firebase.util.Scroll(ref, field);
var list = $firebaseArray(scrollRef);
list.scroll = scrollRef.scroll;
return list;
}
}])
Here's a demo of this in action.
Any help with this is appreciated. Thanks in advance!