I am using AngularJS v1.3.16. I want to reset the form.
I tried $pristine
, $dirty
and $setPristine()
but I got error messages:
HTML:
<form id="userForm" class="form-horizontal ut-form form-validation" role="form" name="userForm" novalidate>
.........
</form>
Code:
$scope.createUser = function () {
$scope.page.view = 'create';
$scope.account = "";
$scope.userForm.$pristine = true;
}
Error messages:
$setPristine()
- TypeError: Cannot read property'$setPristine'
ofundefined
$pristine
- TypeError: Cannot set property'$pristine'
ofundefined
Please can any one suggest me how to solve this problem.
you can use the form name for this.
In your case:
Or directly in the HTML: