重置表单后未删除validation消息

我有一个HTML表单,我使用角度JS进行validation。 在这里,在提交表单后,我调用了reset方法,它将表单输入字段重置为默认值。

但是,当我提交并调用reset方法时,validation消息将显示在输入字段中。 我使用了以下代码。 我不希望在提交表单后看到validation消息。

HTML

Name is reqiured
Description is reqiured

JS代码

  $scope.createChallenge = function() { //get the field and store in db $scope.resetForm(); } $scope.master = {}; $scope.resetForm = function() { $scope.challenge = angular.copy($scope.master); $scope.createvalidation.$setPristine(); } 

 $scope.createChallenge = function() { //get the field and store in db $scope.resetForm(); } $scope.master = {}; $scope.resetForm = function() { $scope.submitted = false; //Try adding this $scope.challenge = angular.copy($scope.master); $scope.createvalidation.$setPristine(); 

}

您似乎正在从resetForm函数中复制表单的原始状态。 这意味着在调用resetForm时它只具有表单的版本。 相反,也许你应该在表单设置和原始时进行该复制。