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?
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
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!