-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ng-required stopped working inside ng-if or ng-repeat, version 1.7.6 #16814
ng-required stopped working inside ng-if or ng-repeat, version 1.7.6 #16814
Comments
I can confirm that there is some kind of issue with 1.7.6 and ng-required. I have a test that fails in 1.7.6 but passes in 1.7.5 My test asserts that when I set an unrequired field to an empty value the ngModel should be $valid. After some debugging it looks like my input has the attr ng-required="false" but also has a $error On the input In the input ngModelCtrl After a bisect and symlinking to my test environment, the commit associated with this issue it 0637a21 |
by default ngRequired is set to true, but the original value can be false and never be updated. Fixes: angular#16814
when ngRequired is initially false the required attribute will now be updated properly. Fixes: #angular#16814
Thanks for investigating it @codymikol, it looks like it's idd introduced in @Narretz commit to prevent multiple validators from initializing. Probably a good idea to get @Narretz involved in the PR review ( #16815 ). |
…y default Previously, in the required validator, we would read the required setting directly from attr.required, where it is set by ngRequired. However, when the control is inside ngRepeat, ngRequired sets it only after a another digest has passed, which means the initial validation run of ngModel does not include the correct required setting. (Before commit 0637a21 this would not have been a problem, as every observed value change triggered a validation). We now use the initially parsed value from ngRequired in the validator. Fixes angular#16814
…y default Previously, in the required validator, we would read the required setting directly from attr.required, where it is set by ngRequired. However, when the control is inside ngRepeat, ngRequired sets it only after a another digest has passed, which means the initial validation run of ngModel does not include the correct required setting. (Before commit 0637a21 this would not have been a problem, as every observed value change triggered a validation). We now use the initially parsed value from ngRequired in the validator. Fixes angular#16814
We confirm the issue on the GlobaLeaks as reported by some users here: globaleaks/globaleaks-whistleblowing-software#2495 |
We will release 1.7.7 early next week. |
…y default Previously, in the required validator, we would read the required setting directly from attr.required, where it is set by ngRequired. However, when the control is inside ngRepeat, ngRequired sets it only after a another digest has passed, which means the initial validation run of ngModel does not include the correct required setting. (Before commit 0637a21 this would not have been a problem, as every observed value change triggered a validation). We now use the initially parsed value from ngRequired in the validator. Fixes angular#16814
…y default Previously, in the required validator, we would read the required setting directly from attr.required, where it is set by ngRequired. However, when the control is inside ngRepeat, ngRequired sets it only after a another digest has passed, which means the initial validation run of ngModel does not include the correct required setting. (Before commit 0637a21 this would not have been a problem, as every observed value change triggered a validation). We now use the initially parsed value from ngRequired in the validator. Fixes #16814 Closes #16820
…y default Previously, in the required validator, we would read the required setting directly from attr.required, where it is set by ngRequired. However, when the control is inside ngRepeat, ngRequired sets it only after a another digest has passed, which means the initial validation run of ngModel does not include the correct required setting. (Before commit 0637a21 this would not have been a problem, as every observed value change triggered a validation). We now use the initially parsed value from ngRequired in the validator. Fixes #16814 Closes #16820
ng-required stopped working,
I am using AngularJS Material tabs,
I have a condition inside each tab for "required" fields.
I have another condition for showing the tabs or not (ng-if).
plunker: http://next.plnkr.co/edit/g6tieIDq9yaEpNre
In this example, the submit button is not working, but the ng-required for the second input (the hidden one) is false!
another example with ng-repeat:
plunker: http://next.plnkr.co/edit/b7STJ5B4Ktcou83y
In this example, the submit button is not working, the second input (inside the ng repeat) is not required.
if we change angular version back to 1.7.5, its working as excepted.
AngularJS version: 1.7.6
Browser: [all ]
Thanks.
The text was updated successfully, but these errors were encountered: