eight04 / angular-datetime

A directive to add the behavior of datetime input on unsupported browsers.
MIT License
93 stars 28 forks source link

Evaluate empty min/max attribute as always valid #31

Closed felixruponen closed 8 years ago

felixruponen commented 8 years ago

I added a string empty check for attrs.min/attrs.max since I am using something like:

<input ng-model="date" datetime="yyyy:MM:dd" min="{{ minDate | date:'yyyy:MM:dd' }}" />

If minDate is undefined (min="") angular-datetime will still compare the ngModel against new Date(attrs.min) which will evaluate to new Date('') which is of course an invalid date. This means the input will always be invalid.

eight04 commented 8 years ago

:+1: Maybe we can just replace angular.isUndefined(attrs.min) with ngModel.$isEmpty(attrs.min)?

felixruponen commented 8 years ago

Sounds good, looks a lot better! I have updated the PR.