I am having issues updating a reference of an object: I have a couple of functions that help me edit a user:
function enableEditUser(user) {
$scope.originalUser = user;
$scope.editUser = angular.copy(user);
}
function SaveUserEdits(form) {
if (form.$valid) {
$scope.originalUser = angular.copy($scope.editUser);
}
}
Everything is working as I would expect. I call enableEditUser(user) from inside an ng-repeat="user in users" and the user gets passed in. When I call SaveUserEdits, the originalUser object does indeed get updated.
I expected that, because $scope.originalUser = user;, that when I update $scope.originalUser the user in users would also be updated (since I thought they were both references to the same object). However, (using ng-inspect) I see that while $scope.originalUser is updated, user is not updated.
Thanks in advance