I have resolved this issue and update the plunk to reflect a working solution. The problem stemmed from the fact that multiple instances of the form were concurrently displayed via ng-repeat. Consequently, the ng-class 'validation' logic was never looking at the proper instance of the associated form fields in any case but the very last one displayed. I modified the behavior to use ng-if to conditionally include the fields only if on the appropriate $index of he ng-repeat. This corrected the issue and is now working properly across all instances.
On Friday, July 24, 2015 at 11:16:50 AM UTC-6, Todd Gould wrote: > > Hello, > > I routinely use ng-class to depict invalid fields in association with the > Angular form controller .$dirty and .$valid values to highlight invalid > entries to the user. I've never had an issue with this before. However, I > recently ran into a scenario where it is no longer working consistently. > > I have a plunk at: http://plnkr.co/edit/YSmwbTQyGBgqVVeebea8?p=preview > Within it, you will be able to see both the correct/desired behavior as > well as the failure case. The mystery, is that both success and failure > are using the same code! Clearly, I am missing something. I suspect it > may be a scope issue, but I have not yet tracked it down to that. > Moreover, nearly identical code is working throughout my application - as > I've scrubbed for differences and not found any, I'm at a loss what is > causing the issue here. > > To see the successful/desired outcome, go to the Plunk. > - Once there, got to Tab 2. > - Select the last vertical tab ('New HLE') > - Type anything into the Name and then click on the Assign button > - A Materials Cost entry field will appear. It expects a numeric value, > but type in some characters instead > - The invalid entry will be detected and the border will change to red > > To See the failure case, enter a similarly invalid input into the > Materials Cost input on either the 'HLE A1' or HLE B2' vertical tabs. The > invalid input is not detected and no red border appears. Again, same code > in both cases. > > What am I missing or doing wrong? > > TIA for your help! > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
