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
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. 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.
Setting $scope.isSubmitted
& yourForm.$submitted
to false before adding "controls" should solve your issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.