Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs ng required关闭模型后未清除通知_Javascript_Angularjs_Twitter Bootstrap_Bootstrap Modal - Fatal编程技术网

Javascript Angularjs ng required关闭模型后未清除通知

Javascript Angularjs ng required关闭模型后未清除通知,javascript,angularjs,twitter-bootstrap,bootstrap-modal,Javascript,Angularjs,Twitter Bootstrap,Bootstrap Modal,我正在使用表单验证所需的Angularjs ng。当我试图用空白表单保存时,它会显示填充值的错误。关闭模型并重新打开后,模型表单验证通知未被清除。 示例 您需要在modal关闭时重置表单。您应该调用模式关闭按钮的重置功能。请参阅下面的代码并进行必要的更改。 在您的模板中,请在单击时调用重置功能- ng-click="reset();" 有很多种方法可以将表单设置为prestine状态,将表单数据复制到temporary object就是其中之一。像 $scope.mainForm = angu

我正在使用表单验证所需的Angularjs ng。当我试图用空白表单保存时,它会显示填充值的错误。关闭模型并重新打开后,模型表单验证通知未被清除。
示例


您需要在modal关闭时重置表单。您应该调用模式关闭按钮的重置功能。请参阅下面的代码并进行必要的更改。 在您的模板中,请在单击时调用重置功能-

ng-click="reset();"
有很多种方法可以将表单设置为prestine状态,将表单数据复制到temporary object就是其中之一。像

$scope.mainForm = angular.copy($scope.new_visa);
在控制器中,请使用以下代码定义重置功能

$scope.reset = function (){
        $scope.submitted = false;
        $scope.new_visa = angular.copy($scope.mainForm);
        $scope.visa_form.$setPristine();
      }
$setPristine
函数将窗体设置为预初始化状态。当我们在提交或重置表单后重新使用表单时,它非常有用。这里有一个工作程序来检查您的完整代码。

使用
$setPristine()重置表单的方法。看

您可以这样打电话:
$scope.myForm.$setPrestine()

将您的代码或其代码片段的详细信息显示出来,以便我可以尝试并提供帮助。请查看此代码。参见第19行和第20行
myForm
是表单元素的
name