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
Post a Comment