我有这样的事情:
$scope.last_good_configuration = $scope.storage;
在$scope.last_good_configuration中我保留了最后的好设置.
当用户输入输入的坏值时,例如我想做的大整数:
$scope.storage = $scope.last_good_configuration;
但我的$scope.last_good_configuration始终与$scope.storage相同.如何停止更新$scope.last_good_configuration?我必须以某种方式评估我的范围?
解决方法
您需要复制或克隆原始对象. Angular有一个内置的方法:
angular.copy.
$scope.last_good_configuration = angular.copy($scope.storage); //Edits must be at least 6 characters workaround