Angular.js: form.FormController.$valid is undefined in Angular 1.4.7

Created on 28 Oct 2015  路  11Comments  路  Source: angular/angular.js

I have met a bug while developing a site using angularjs,
when I am trying to test the validity of my form from controller by calling $valid property, it is undefined.
I have logged entire form controller and $valid is actually undefined, what could be the solution?

proof

Most helpful comment

@KeyKrusher Yes, thanks, mate! The problem was in my custom validation directive, which was not returning true in case, if there is no error!

All 11 comments

I assume this is caused by async validators? See #11167

Yes, it seems to be, but what would be the solution in this case? How can I call the validation of the entire form in my controller?

Can you paste in all of the code? I'm not really sure...

@NSLS

@KeyKrusher Makes no sense, because I have the code divided into many different pieces, but i can try to explain what is happening.

Because I have custom directives like ng-dropdown, I needed to connect angular form validation to the selected values.
I only managed to make it working by adding hidden input with it's model and then calling $validate of this input field directly from dropdown on-update callback

@NSLS True. I wasn't looking it all the way through.

@NSLS You have both valid and invalid listed as undefined... But I don't think that would do anything.

@KeyKrusher Yeah, in the examples with the async validation, form "decides" it's validity after few seconds, but in my case it just stays undefined

Could there be a error in any of the function? Such as it being redefined?

@KeyKrusher Yes, thanks, mate! The problem was in my custom validation directive, which was not returning true in case, if there is no error!

Issue solved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

butchpeters picture butchpeters  路  3Comments

tdumitrescu picture tdumitrescu  路  3Comments

brijesh1ec picture brijesh1ec  路  3Comments

awerlang picture awerlang  路  3Comments

kishanmundha picture kishanmundha  路  3Comments