I do not know why when I assign 1 scope to another like this:
$scope.test1 = "hello";
$scope.test1 = $scope.test2;
Sometimes if I change $scope.test2, $scope.test1 changes too, and sometimes not. And also sometimes if I change $scope.test1, $scope.test2 changes too.
Why is this happening? maybe I am in a promise or something like that?
I do not need a solution I just want the theory of this, angular.copy is the solution.
Here is my code:
$scope.topicsQuery.should = $scope.appliedOrFilters;
$scope.appliedOrFilters.splice(i, 1);
$scope.topicsQuery.should.splice(filtersToDelete[i],1);
Then if appliedOrFilters changes topicsQuery.should will change too and if topicsQuery.should changes appliedOrFilters will change too.
But if i put this:
$scope.topicsQuery.should = [];
nothing changes.
Does .splice change the property of an object?