How to update an array element?

Hi!
Start at the end of the issue. You need to update only those array elements that have changed. You cannot update the entire array!

[{"id":87510,"name":"1","date":1506983543"}{"id":87512,"name":"2","date":1506983543"}]

Controller:
$scope.getData = function() {
 $http.get('/api/arr/', {
 cache: true
 }).then(successCallback, errorCallback);
};

 function successCallback(response) {
 if ($scope.arr== null) {
 $scope.arr= [];
 angular.merge($scope.arr, response.data);
}
// but what to do if you want to upgrade?
//tried to do so:

 for (var i = 0; i < $scope.arr.length; i++) {
if ($scope.arr[i].name!=response.data[i].name) {
 $scope.arr[i].name= response.data[i].name
}


}


doing a get request every second on a timer, but despite this, never the condition the $scope.arr[i].name!=response.data[i].name because why the data is the same as if I have the same link. Although the merge should work otherwise.

How to upgrade a single item of the array without refresh the entire array with a get request?

The third day I already, does not work. Very helpful would be an example. Thank you!
June 14th 19 at 20:36
3 answers
June 14th 19 at 20:38
Solution
He decided, needed angular.copy to use.
June 14th 19 at 20:40
If you do it in ng-repeat then you put something worth trackBy to put some custom.
Well generally 1. angular.merge deprecated, 2. call it for Merja arrays - some tin
June 14th 19 at 20:42

Find more questions by tags Angular