javascript - How to not update a model until form submission in Angular? -


i'm looking angular not update model until user submits form. or, in way, update model only when user has submitted form.

<form ng-submit="process()">     value : {{ model.property }}     <input type="text" ng-model="model.property">     <button type="submit">submit</button> </form> 

i thinking of ng-model-options="{ updateon: null }" doesn't work.

is possible without getting "hacky" (like getting each input's value on submit)?

you should clone object using angular.copy.

 $scope.formdata = angular.copy($scope.model);  <form ng-submit="process()">     value : {{ formdata.property }}     <input type="text" ng-model="formdata.property">     <button type="submit">submit</button> </form> 

then on process update model.

 $scope.model = angular.copy($scope.formdata); 

you using temporary model instead of "real" one.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -