angularjs - Add items end of angular ng-repeat list -


i have ng-repeat list starts 10 items. add new items @ end of list (bottom) if run function add items top of list.

i know can add items .push() , .unshift() not working code use.

this code (i use code snippet pubnub fetch history items):

$scope.messages = [];  $scope.loadmore = function() {      var timetoken = $('.lastmessage').attr('timetoken');     console.log(timetoken);      // populate message history     pubnub.nghistory({         start: timetoken,         channel: $scope.channel,         count: 5,     });  }; 

html:

<ion-item ng-repeat="message in messages track $index"> 

you can use orderby ng-repeat. looks have time value in each element, can use order list.

<tr ng-repeat="item in history | orderby:'start'"> 

if have id in elements can use "track by" if have instance id field. allows angular show duplicates. doesn't seem issue. wiki:

by default, ngrepeat not allow duplicate items in arrays. because when there duplicates, not possible maintain one-to-one mapping between collection items , dom elements.

if need repeat duplicate items, can substitute default tracking behavior own using track expression.

<tr ng-repeat="item in history track $id"> 

Comments