Mahyar Pasarzangene
Mahyar Pasarzangene

Reputation: 373

$invalid and $valid on my angularjs form are both undefined

I have read this post both myForm.$valid & myForm.$invalid are undefined on angular form?

But actually my problem is not the same , I have defined a form like this

<form name="EntityForm" role="form" novalidate ng-submit="EntityForm.$valid && save()" id="EntityForm"></form>

And I have Modal that opens this form template , in some point of my program I can open the Modal without problem and form translate to something like this :

<form name="EntityForm" role="form" novalidate="" ng-submit="EntityForm.$valid && save()" id="EntityForm" class="ng-pristine ng-scope ng-invalid ng-invalid-required ng-valid-maxlength ng-valid-pattern ng-invalid-iran-national-id ng-valid-minlength"></form>

And in some other point it translate to something like this :

<form name="EntityForm" role="form" novalidate="" ng-submit="EntityForm.$valid && save()" id="EntityForm" class="ng-pristine ng-scope ng-valid-maxlength ng-pending ng-invalid-required ng-valid-pattern ng-invalid-iran-national-id ng-valid-minlength">

when I compared two situation I found out that somehow angularjs not resolves "ng-invalid" correctly in second situation.

How it can be possible that angularjs not resolving valid and invalid directives on form ?

Thanks in advance .

Upvotes: 0

Views: 353

Answers (1)

Mahyar Pasarzangene
Mahyar Pasarzangene

Reputation: 373

I solved my problem with checking on all elements in the form , I had a custom directives to check some validation on my form , even tough there was no errors in console or other ways of debugs values for $invalid and $valid on form got undefined. So if you encountered this in future double check on all model elements and directives inside the form .

Upvotes: 1

Related Questions