I use firebase to save messages that have the following data:
createdAt: "Sun Apr 03 2016 18:32:46 GMT-0300 (BRT)"
What I'm trying to achieve is to first get the most recent messages and then load the old ones while the user scrolls down.
With messages received using ngInfiniteScroll, I can order desc using <div ng-repeat="post in posts | orderBy:'-createdAt'"> , but ngInfiniteScroll first returns the old messages. I order, but I order the elders.
I already tried using the same logic ( "-createdAt" ) in ngInfiniteScroll, but was not effective.
My js pretty much:
var baseRef = new Firebase(FBURL).child("posts"); var scrollRef = new Firebase.util.Scroll(baseRef, "createdAt"); $scope.posts = $firebaseArray(scrollRef); $scope.posts.scroll = scrollRef.scroll;
Safety and rules:
"posts": { ".read": true, ".indexOn": "createdAt", "$post": { ".read": true, ".write": true, "$other": { ".validate": true } } }
source share