Remove ng-submitted after successful submission
Asked Answered
W

1

6

I have a form that submits via an api and can be reused immediately after the post request has finished.

For validation styling requirements I need to remove the css class ng-submitted from the <form> I can't seem to find an angular method for clearing it, or resetting the form.

I have tried:

myForm.$submitted = false;

but this does not remove the ng-submitted class

Does such a method exist in angular 1.3?

Wagshul answered 5/3, 2015 at 11:59 Comment(0)
L
9

hi I think you need to do this:

myForm.$setPristine();
myForm.$setUntouched();

this will clear the submit state and all fields will be untouched, this does not clear the field values though so if you want that you need to do this separately

Lynnett answered 5/3, 2015 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.