eight04 / angular-datetime

A directive to add the behavior of datetime input on unsupported browsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ngRequired not being respected.

crazyjat opened this issue · comments

I have a input text element with the datetime and ngRequired directives on it. No matter what the value of ngRequired, the ng-valid-required class is added to the element.

I have looked at the source for the datetime directive and could find no obvious place this was being done.

How can I get ngRequired to work in conjunction with the datetime directive?

commented

Seems that we have to overwrite NgModelController.$isEmpty.
https://docs.angularjs.org/api/ng/directive/ngRequired

I don't understand how that would fix the issue where setting ng-required="false" would instead cause the control to appear as required.

The issue I'm currently having is that no matter what the value of ng-required is the control always appears as required.

commented

I had misunderstood the question.

ng-invalid-required is added to the class list only if the input is empty and the required attr is set. Otherwise, ng-valid-required is added.

So when you set ng-required="false", the class list always contains ng-valid-required.

By having ng-required="false" it causes a datetime validation error not a required validation error.

commented

Fixed in 4.1.0.