angularjsangularjs-ng-form

Remove ng-submitted after successful submission


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?


Solution

  • 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