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); } 

see more


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -