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

fix(input.min/max) re-validate input[type=number] when min/max changes - #6369

Closed
quazzie wants to merge 1 commit into
angular:masterfrom
quazzie:fix_minmaxattr
Closed

quazzie wants to merge 1 commit into
angular:masterfrom
quazzie:fix_minmaxattr

Conversation

@quazzie

@quazzie quazzie commented Feb 20, 2014

Copy link
Copy Markdown
Contributor

Value was not re-evaluated when min/max changed.

Value was not re-evaluated when min/max changed.
@mary-poppins

Copy link
Copy Markdown

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#6369)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@njs50

njs50 commented Apr 1, 2014

Copy link
Copy Markdown

If this isn't going to be merged soon it might be worthwhile updating the docs to note that the expected behaviour doesn't work?

@tbosch

tbosch commented Apr 2, 2014

Copy link
Copy Markdown
Contributor

We are working on refactoring the forms validation, see #6928.

@njs50

njs50 commented Apr 2, 2014

Copy link
Copy Markdown

Nice!

If it does slip from 1.3 it would be nice to have this PR in the meantime.

@greglockwood

Copy link
Copy Markdown

It appears that this PR does not address a related issue where if the value for the min/max attribute is "" (empty string) when the input is compiled, but changes to a valid number later, then the validator functions are never added correctly, even when the attribute value changes.

This is because of the if (attr.min) / if (attr.max) conditions that will evaluate as false if the attribute value is initially blank.

This is most easily observed if you try to use an interpolated expression as the value for the min/max attributes where the expression initially evaluates to undefined but in a subsequent cycle evaluates to a number:
e.g. <input type="number" ng-model="some.property" min="{{ somePropMetaData.min }}"> where $scope.somePropMetaData gets set after the input has been compiled.

There is a workaround where you ensure that a non-empty value is initially set for the min/max attribute so the if condition passes:
<input type="number" ng-model="some.property" min="{{ somePropMetaData ? somePropMetaData.min : 0}}">
but it is not clear from the documentation that such a workaround is required and it requires close examination of the source code to notice that it is.

@Narretz

Narretz commented Jul 4, 2014

Copy link
Copy Markdown
Contributor

Last remnants of this issue are discussed here: #2404

@Narretz Narretz closed this Jul 4, 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.

6 participants