从$ scope变量中提取值?

时间:2015-03-20 19:54:04

标签: javascript angularjs angularjs-scope

如何将常规javascript变量分配给角度$ scope变量的当前值而不绑定它们的值?

//$scope.var1 is initialized to some value, say 5
var v2 = $scope.var1;
//$scope.var1 is changed to 7

我希望v2仍然是5,而不是7。

1 个答案:

答案 0 :(得分:1)

var v2 = angular.copy($scope.var1);