Skip to content
This repository was 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
airato wants to merge 1 commit into
angular:masterfrom
airato:fix-min-max-length
Closed

airato wants to merge 1 commit into
angular:masterfrom
airato:fix-min-max-length

Conversation

@airato

@airato airato commented Jun 16, 2014

Copy link
Copy Markdown
Contributor

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

airato commented Jun 16, 2014

Copy link
Copy Markdown
Contributor Author

Fix for v1.2.x branch - #7858

@Narretz

Narretz commented Jun 16, 2014

Copy link
Copy Markdown
Contributor

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

airato commented Jun 17, 2014

Copy link
Copy Markdown
Contributor Author

@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

airato commented Jun 18, 2014

Copy link
Copy Markdown
Contributor Author

@matsko, need you here

@Narretz

Narretz commented Jul 25, 2014

Copy link
Copy Markdown
Contributor

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

airato commented Jul 26, 2014

Copy link
Copy Markdown
Contributor Author

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

@Narretz

Narretz commented Sep 5, 2014

Copy link
Copy Markdown
Contributor

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