Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(NgModel): use string representation of the value in the ngMinlength and ngMaxlength #7856

Closed
wants to merge 1 commit into from

Conversation

airato
Copy link
Contributor

@airato airato commented Jun 16, 2014

There is an issue - if ng-model value set to a nonstring (via js), the ngMinlength and ngMaxlength don't work properly.
Issue example http://plnkr.co/edit/y65LU7xJFSi4L9Ui4WqZ?p=preview

Fixes #7848

@airato
Copy link
Contributor Author

airato commented Jun 16, 2014

Fix for v1.2.x branch - #7858

@Narretz
Copy link
Contributor

Narretz commented Jun 16, 2014

I think there's something else going on. For example, if you change the model value to string, it's still not working initially. If you manipulate the model value so it's set after a short timeout, the validation works. Same when typing in the input. I think this is related to the validation being broken in some cases when the form is first compiled, see a8c7cb8

@airato
Copy link
Contributor Author

airato commented Jun 17, 2014

@Narretz , here is example with fixed ngMaxlength directive
http://plnkr.co/edit/MtOksjSzy5mPXpyHPiZe?p=preview

if you change the model value to string, it's still not working initially

I couldn't make that in the plunker.

Maybe there are some issues with validators, but i just fixed little bug with ngMaxlength and ngMinlength. This directives expected only strings previously, and couldn't get .length of number or object. With arrays it was tricky.

@airato
Copy link
Contributor Author

airato commented Jun 18, 2014

@matsko, need you here

@Narretz
Copy link
Contributor

Narretz commented Jul 25, 2014

I personally think using the viewValue as in #7968 is more consistent over the board, because some input types will not have a length property on the model.

@airato
Copy link
Contributor Author

airato commented Jul 26, 2014

@Narretz , I agree, using the viewValue seems the right way.

@Narretz
Copy link
Contributor

Narretz commented Sep 5, 2014

This should be fixed in master for all supported input types.

@Narretz Narretz closed this Sep 9, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ngMaxLength with integer only input fails
2 participants