This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
maxlength directive doesn't work with numbers #8811
Closed
Description
The maxlength
directive is broken when used with Number
model values in the current Beta. When I try using timepicker
from angular-bootstrap, the hours/minutes inputs become invalid as soon as they reach values >= 10
. This happens because, for the sake of readability, values < 10
are prefixed with a zero and saved to the model as strings. Values >= 10
are saved as numbers, which makes this offending line in the directive:
return ctrl.$isEmpty(value) || value.length <= maxlength;
fail, as value.length
equals to undefined
for Number
s. Changing the code to
return ctrl.$isEmpty(value) || String(value).length <= maxlength;
seems to work just fine.
Thanks in advance for the fix.
Metadata
Metadata
Assignees
Labels
No labels