I need to copy the data in the scope, such as $scope.a to $scope.b. I found that when $scope.b is changed, $scope.a will automatically change, but I don’t want the two of them to automatically change. Data binding. I use var c = $scope.a;$scope.b = c; data will be automatically bound between them. What should I do to prevent them from being automatically bound?
PHP中文网2017-05-15 17:00:01
C If it is an object, a and b actually point to the same object. Using angular.copy to make a copy can solve the problem, but you may need to review whether this design is reasonable. Data-driven development should ensure that the data is consistent and unique. .
cIf it is a basic type, such as strings and numbers, the situation you mentioned should not happen