Working on a form for a user to edit their details based on a variable on the $rootScope (could also be $scope).
$rootScope.formData = $rootScope.user;
In the view, there is an ng-model on the input:
ng-model="formData.email"
The behavior I expect is to update the model and only $rootScope.formData will update, but instead, both update.
Is there a way to break the relationship between the two?
useris a reference. Objects in JS are passed as reference. That's it. You can always call clone or cloneDeep (e.g. lo-dash). I would suggest rethink your design based on the fact, that JS behaviour is passing by reference