Angular.js: ng-required stopped working inside ng-if or ng-repeat, version 1.7.6

Created on 18 Jan 2019  路  4Comments  路  Source: angular/angular.js

  • [ X] bug report

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.

regression

Most helpful comment

We will release 1.7.7 early next week.

All 4 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

image

In the input ngModelCtrl

image

After a bisect and symlinking to my test environment, the commit associated with this issue it 0637a2124c4515311a317e0e39926521228fc0af

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 ( https://github.com/angular/angular.js/pull/16815 ).

We confirm the issue on the GlobaLeaks as reported by some users here: https://github.com/globaleaks/GlobaLeaks/issues/2495

We will release 1.7.7 early next week.

Was this page helpful?
0 / 5 - 0 ratings