Thank you for the suggestion. $scope.frm_form.$setPristine(); looks like an Angular 1 solution. I was looking to do it in Angular 2.
On Thursday, January 14, 2016 at 12:58:55 AM UTC-5, Nagesh Dhanashetti wrote: > > touched means user has changed something on the form fields. It is just > opposite of pristine (reset state). > > To get back to the original form state, you can use setPristine method > like this: $scope.frm_form.$setPristine(); > Hope it works for you. > > On Thursday, January 14, 2016 at 12:26:28 AM UTC+5:30, JG wrote: >> >> I have a component, containing an HTML form. It is using "touched" and >> "valid" properties to display error message. >> >> <span [hidden]="!someProp.touched || someProp.valid" >>> class="form-error-message">required</span> >> >> >> When the form is submitted, I create a "new" model used by the form: >> "this.model >> = new SomeFormModel();" >> When I do that, the "pristine" and "touched" properties reflect the old >> state, so the error message is displayed. >> >> Is there a way to reset the state? If not, how should I handle situation >> when upon form submission, it does not need to be redrawn, only reset to >> all inputs being empty? >> >> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
