javascript - How to bind a $scope variable to a normal variable in AngularJS? -
in angularjs controller, have variable $scope.name
assigned input's ngmodel
.
i wanted save value of $scope.name
normal variable, process in controller without changing value of input box.
so did var name = $scope.name
the issue is, 2 seem linked... when change value of name
, value of $scope.name
changes, , changes value of input box.
how can stop this? how can assign $scope
variable normal variable, once, without continued binding?
thank you!
you need use angular.copy()
like:
var name; $scope.name = 'name'; function copy(){ name = angular.copy($scope.name); }
Comments
Post a Comment