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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -