razer90 razer90 - 3 months ago 24
AngularJS Question

prevent form from becoming invalid after press submit in angularjs

I did a validation using:

ng-show="myForm.name.$invalid && !myForm.name.$pristine"

Everything works perfectly, but when I press 'submit', I need to empty the input fields in this way:

$scope.people.name = '';
$scope.people.surname = '';

so the form becomes invalid after the submit...is there a way to prevent that? I need empty fields but a valid form...


I guess after clearing your model variables you need to set forms $pristine property