I have one array in Angular JS: $scope.messages = [];
In template I do ng-repeat:
<div ng-repeat="item in messages"></div>
When I try to do add a new element to the end of array like as:
angular.forEach($scope.messages, function (value, key) {
$scope._lastMsg = key; // Get key of last element of array
});
$scope.messages[++$scope._lastMsg] = obj; // Do increment of next key and add new element obj
This way adds element not at end of array, always differently.
push()function ?