Как сказал @Sajjad Shahi, вы можете использовать сервис $timeout
. Может быть, что-то вроде следующего. Вы можете установить желаемую задержку и размер патрона. Используйте ваш массив $scope.channel
как srcArray
, а пустой массив yourArrayToDisplay
как destArray
. Замените channel
на yourArrayToDisplay
в директиве ng-repeat
. Это должно дать вам желаемый результат, насколько я могу следить.
var dalayedChunkHandler = {
chunkSize: 1,
delay: 2000,
timeout: null,
srcArray: [],
destArray: [],
dalayedChunk: function(){
var _this = this;
var len = _this.destArray.length;
Array.prototype.push.apply(_this.destArray,_this.srcArray.slice(len, len + _this.chunkSize));
if(_this.srcArray.length > _this.destArray.length) _this.start();
},
start: function(){
var _this = this;
_this.timeout = $timeout(function(){_this.dalayedChunk.call(_this)}, _this.delay)
}
};
$scope.yourArrayToDisplay = []; // use this array for ng-repeat
dalayedChunkHandler.destArray = $scope.yourArrayToDisplay;
dalayedChunkHandler.srcArray = $scope.chatHistoryArray; // the array you got
dalayedChunkHandler.start();