`http://plnkr.co/edit/kAt9B3GrO8m8TT7lUHt6?p=preview`
Hey friends, can you please tell me how to reset form values in less steps instead of making each and every value null?
I have a pattern allowing alphabets and when I try to reset form, I want both input and it's error message to be gone. $setPristine only clears the form if i enter right pattern and reset but I want the wrong input like 453453 / =-=- to be gone along with its error style on reset.
Please help..
You can follow the angular docs example and copy over your data using a master if you want all fields reset.
If you want just the invalid field reset you would need to check each field and reset them if they are invalid.
Update your plunker.
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $compile) {
'use strict';
$scope.master = {
name: ""
};
$scope.data = angular.copy($scope.master);
$scope.reset = function() {
$scope.data = angular.copy($scope.master);
$scope.form.$setPristine();
}
});