[英]Not validating new controls after submitting form in angularjs
We have a form which we are submitting on save button. 我们有一个要在保存按钮上提交的表格。 There are some validation firing on save.
保存时会触发一些验证。 We are submitting form using
$scope.isSubmitted= true
and $scope.watch
on $scope.isSubmitted
for error highlighting 我们使用
$scope.isSubmitted= true
和$scope.watch
上的$scope.isSubmitted
提交表单以突出显示错误
After submitting and validating the form, if there is any new controls add to form on the basis of ng-if
condition the new controls are also validated. 提交并验证表单后,如果有任何新控件在
ng-if
条件的基础上添加到表单中,则新控件也将得到验证。 So my question is how to prevent new controls which being added after submitting the form to validate and only validate after resubmit. 因此,我的问题是如何防止在提交表单进行验证后才添加新控件,而仅在重新提交后才进行验证。
The problem is that when you add new "controls", you update your scope which is then re-evaluate. 问题是,当您添加新的“控件”时,您将更新范围,然后重新进行评估。
$scope.isSubmitted
being true (and maybe yourForm.$submitted
too) new values are verified on the fly. $scope.isSubmitted
为true(也可能是yourForm.$submitted
),新值将即时验证。
Setting $scope.isSubmitted
& yourForm.$submitted
to false before adding "controls" should solve your issue. 在添加“控件”之前将
$scope.isSubmitted
和yourForm.$submitted
为false应该可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.