I'm trying to display the latest ads, I have some ads saved into Firebase and want to display the lasts added, they are stored with a timestamp property.
If I create the ng-repeat without limitTo, it works as expected, but when I use limitTo or even limitToFirst, it doesn't work as expected, it displays correctly the number of items I was going to display at the beginning but it skips some of them, and when I click the loadmore button, it loads more ads and display the ones that supposed to be there from the beginning.
Note that it should display two ads with dates 27th oct but it only displays one.
Here a plunkr with a demo: https://plnkr.co/edit/Ae8rlbD8Uob5TrAHrivz?p=preview
app.controller('publicCtrl', function($scope, $firebaseArray) {
$scope.loadmore = 6;
$scope.latest = "-Addate";
var listads = new Firebase("https://milocal.firebaseio.com/Users/Ovalle");
$scope.listads = $firebaseArray(listads);
$scope.loadmoreads = function(){
//console.log("Cargando anuncios");
$scope.loadmore += 2;
$scope.listads = $firebaseArray(listads);
console.log($scope.loadmore);
}
});
in the HTML:
ng-repeat="ads in filteredAds = (listads | limitTo: loadmore | orderBy: latest)"
Hope someone can explain me what I'm doing wrong.
Thanks.