Is there a way to edit an array of objects in AngularJS, linked to the view through ng-repeat, without updating the scope until all objects have been modified?
Consider this scenario:
I need to update each object in the array and only then reflect the changes in the $scope. Since the array consists of objects, simply copying them into another variable is not feasible.
<div ng-click="updateAll()" ng-repeat="obj in array">obj.value</div>
angular.module("test", []).controller('Ctrl', function($scope) {
$scope.array = [{val: 1}, {val: 2}, {val: 3});
$scope.updateAll = function() {
for (var i = $scope.array.length - 1; i >= 0; i--) {
$scope.array[i].val2 = i;
};
};
});