My form initiates a GET request to the server upon loading, receiving data that is stored in 'master' and then copied to 'local' as shown below.
$scope.dirty = false;
init(data);
function init(data) {
$scope.master = angular.copy(data.data);
$scope.local = angular.copy($scope.master);
}
The 'local' object is used as the model for my form, along with submit and reset buttons. I monitor changes in the 'local' object like this:
$scope.$watchCollection('local', function (newLocal, oldLocal) {
$scope.dirty = !angular.equals(newLocal, $scope.master);
});
If the 'dirty' flag is true, I know that the data has been modified. However, due to AngularJS adding $$hasKey to $scope.local objects, the $scope.dirty variable always sets to true.
Is there any way to resolve this issue? I am new to AngularJS, so it may be a basic question but I'm struggling to find a solution.