-
-
Save katowulf/dd354f1f236e3086f61f to your computer and use it in GitHub Desktop.
Example of Infinite scroll in Angular using ngInfiniteScroll and Firebase (uses http://firebase.github.io/firebase-util/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('app', ['firebase', 'infinite-scroll']); | |
app.controller('ctrl', function($scope, $firebaseArray) { | |
$scope.world = 'world'; | |
var baseRef = new Firebase('https://fbutil.firebaseio.com/paginate'); | |
var scrollRef = new Firebase.util.Scroll(baseRef, 'number'); | |
$scope.items = $firebaseArray(scrollRef); | |
$scope.items.scroll = scrollRef.scroll; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body ng-app="app" ng-controller="ctrl"> | |
<h2>Hello {{world}}!</h2> | |
<div infinite-scroll="items.scroll.next(10)" infinite-scroll-distance="1"> | |
<div ng-repeat="item in items"> | |
{{item.$id}}: {{item.number}}, {{item.string}} | |
</div> | |
</div> | |
</body> |
@henry74 could you provide an example?, I'm trying to do the same thing.
@henry74 an example would be awesome!
Don't use $priority as that is going away. Instead add a new field createdAtDesc and set it to 0 - Date.now() to create a negative number which can be used for reverse chronological order. Hope that helps - sorry didn't see these comments sooner.
{
createdAt: Firebase.ServerValue.TIMESTAMP,
createdAtDesc: 0 - Date.now()
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Never mind - figured it out by using $priority and passing that in as the orderBy field