0

Scouring for an answer online and none of the solutions seem to work that I have found so far. I have a Python script which uses push() to enter in new entries into my Firebase. From what I read it creates a unique ID which includes a datetime stamp so it will always be entered at the bottom. Now I am trying to display the entries on my angularfire web app but the most current entry is displaying on the bottom of my page....how do I flip this around?

Main.js

'use strict';

angular.module('App', ["firebase"])
  .controller('MainCtrl', ['$scope', '$firebase',
    function ($scope, $firebase) {
     var ref = new Firebase([URL])
     $scope.messages = $firebase(ref.limit(10)).$asArray();
   }]);

Main.html

<div class="jumobotron" ng-repeat="msg in messages">
 <img class="img-responsive" ng src="[URL]/{{msg.filename}}"/>
</div>

Anyone have an idea what I should use? I tried using OrderBy and OrderByPriority but I never set priorities and push doesn't create priorities for the elements. I was hoping to just use the unique IDs which are formatted by Firebase as -JWNzwoIPWY_hSNmnzhU.

I have also tried the endAt() method but it doesn't reverse order

'use strict';

angular.module('App', ["firebase"])
  .controller('MainCtrl', ['$scope', '$firebase',
    function ($scope, $firebase) {
     var ref = new Firebase([URL]/messages)
      $scope.messages = $firebase(ref.endAt().limit(10)).$asArray();
   }]);
DeucePie
  • 163
  • 3
  • 16
  • See http://stackoverflow.com/q/25611356/209103 – Frank van Puffelen Sep 09 '14 at 22:37
  • I found this solution and it doesn't reverse the order for me. I've added the code as I entered it using the .endAt() – DeucePie Sep 09 '14 at 23:39
  • But it does return the last 10 records right? And if you read the two answers on the post Frank linked, you'll see how to reverse the order of the array locally. – Kato Sep 10 '14 at 05:34
  • @Kato I ran across this solution prior to posting this and I don't see how to reverse the array... the ref.endAt().Limit(10) does limit my entries to the last 10 but the latest entry is on the bottom of my web app... – DeucePie Sep 10 '14 at 18:54
  • See the code. It utilizes unshift to push them into an array in reverse order. – Kato Sep 10 '14 at 20:45

0 Answers0