in my HTML :
<form class="form_page login-frm" name="loginForm" novalidate>
<input type="email" ng-model="data.username" name='username' required autofocus>
<div class="info-message">
<small ng-show='(loginForm.username.$error.required || loginForm.username.$error.email) && loginForm.username.$dirty'>The acceptable format for the username includes an '@'.
</small>
</div>
<button class="btn btn-primary" ng-click="cancel()">Cancel</button>
</form>
In Controller:
$scope.cancel = function() {
$scope.loginForm.$setPristine();
angular.element(this)[0].loginForm.$setPristine();
delete $scope.data.username;
};
But after this also, if the username is incorrect and error message is showing and the cancel button is clicked then the error message gets erased but the username field never empties.How to empty the username also.And also after deleting the value why is it visible?