As shown in the title, there is a form in which a p is controlled by a check box. If checked, the input element under the p will be displayed, and verification is required. If not checked, there is no need to verify hidden elements when the form is submitted. In the case of ng-if, even if validator="[required]" is added to the displayed elements, they will not be verified after being displayed. In the case of ng-hide, validator="[required]" will also perform required verification on the hidden elements.
Supplement: If you write the required attribute directly in the input tag, it seems that the desired effect can only be achieved under IE.
It would be great if you write js directly for verification,
I have never used ang_js, but I suggest that the author directly wraps an if judgment outside the section that verifies the hidden field input in the method it uses to verify the form. This should be able to achieve the minimum modification requirements without affecting the overall performance. Verification style, hope it helps you
ng-required
I always use ng-if, no problem. form submission.
Anything written in the controller should be returned when the form verification fails.
The hidden form is set to non-required