Pregunta

I'm having trouble sorting larger Arrays with an angularFireCollection binding:

$scope.offers = angularFireCollection(new Firebase(url));

while having in my template the code:

<tr ng-repeat="offer in offers | limitTo:100 | orderBy:'createdTimestamp':true">

While the offers.length is < 100, new items are correctly displayed on top. After 100 items, the sorting stops working at all.

¿Fue útil?

Solución

The issue is your expression order. "offer in offers | limitTo:100 | orderBy:'createdTimestamp':true" first gets the first 100 elements of offers, then orders. What you want is to order, then limit, so you want to use the string "offer in offers | orderBy:'createdTimestamp':true | limitTo:100". You can see what I mean in the following jsFiddle, where the first list limits the array and then tries ordering while the second orders, then limits: http://jsfiddle.net/qE5P9/1/.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top