Skip to content
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
@hon2a

Description

@hon2a

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 Numbers. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions