Hi Friend,
I have spend a lot of time but dont know why my code not work,
I have a ng-list and model is a array message, problem is:
- new message add in array : i place a log length of array before add
and after add, length have change + 1, but next time, i check array
and dont see object added to array
My Code:
if (data.messages.length > 0){
console.log('message ' + JSON.stringify(data.messages));
$timeout(function() {
data.messages.forEach(function(mes) {
mes.createDateView = new Date(mes.createDate);
console.log('message begin push: ' + JSON.stringify(mes) + ' length: '+ $scope.messages.length);
$scope.messages.push(mes);
console.log('message after length: '+ $scope.messages.length);
MessagesTable.add(mes);
});
$scope.$apply();
}, 0);
$timeout(function() {
viewScroll.scrollBottom();
}, 2000);
}