You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
the same thing happens to max validation, makes me wonder, does the validation directive accept expression? if not, how do we properly pass parameters to them?
The ngMaxlength, ngMinlength and perhaps other pseudo-directives used by the input directive do not evaluate the value of the attribute in the current scope, but just cast it to a integer.
I would love to see this get fixed as well, the suggestion by @hkdobrev works great for me...
I'm new to these parts (loving AngularJS!), but it seems things may have stalled on this tiny issue? So as above, any input from the AngularJS core developers would be gratefully received! @IgorMinar@btford
Oh, just noticed #1588 was closed a few months back due to failing tests. Anybody care to have a second look at that pull request to get the tests passing?
@caitp the ones I saw are closed.
If you know of one that's still active and solves this, reference it so this issue gets closed when the PR gets merged?
they're closed, but they could be fixed up and checked in, it's not too difficult. The issue is that we can't seem to decide whether we actually want to support them or not, because once they're expressions, people will start asking for them to be $watched and etc. It gets ugly
We could watch them.
Constants will be unwatched anyway (e.g. 6), and bind-once can be used if you know the value never changes, and you want to optimize your application.
you know what's interesting @rodyhaddad, we don't actually consider an empty expression ("") as a constant, so we watch those forever if they get watched. we should probably fix that.
There is one issue with allowing for dynamic min/max-length.
Description: If there's a valid value in an input that respects the max-length constraint, and suddenly the max-length drops to 1, what would happen to the validation? Obviously the value is no longer valid, but do we have a way to re-run the validations and make the model value undefined?
wait, it looks like it already got merged. is there a test for that? (this is about re-validating minlength/maxlength if their value changes --- ie when the observe listener is called. it is not about dealing with parsed expressions, but it could)
Activity
hyusetiawan commentedon Sep 23, 2012
the same thing happens to max validation, makes me wonder, does the validation directive accept expression? if not, how do we properly pass parameters to them?
feat(input): make expressions work for ng-Maxlenth and ng-Minlength
hkdobrev commentedon Feb 8, 2013
👍 I think I have found the problem here: https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L494
The ngMaxlength, ngMinlength and perhaps other pseudo-directives used by the input directive do not evaluate the value of the attribute in the current scope, but just cast it to a integer.
Any input from the AngularJS core developers? @IgorMinar @btford
I think a
int(scope.$eval(attr.ngMaxlength))would do the job. What do you think?timneedham commentedon Apr 27, 2013
I would love to see this get fixed as well, the suggestion by @hkdobrev works great for me...
I'm new to these parts (loving AngularJS!), but it seems things may have stalled on this tiny issue? So as above, any input from the AngularJS core developers would be gratefully received! @IgorMinar @btford
bowsersenior commentedon Jun 4, 2013
Just ran into this same problem and wasted a lot of time. It would be awesome if this could get fixed soon. Thanks!
bowsersenior commentedon Jun 4, 2013
Oh, just noticed #1588 was closed a few months back due to failing tests. Anybody care to have a second look at that pull request to get the tests passing?
blowsie commentedon Sep 16, 2013
+1 for fixing this! Is it planned to be fixed for version 1.2? or anytime soon?
the-spyke commentedon Dec 3, 2013
Any progress on this?
hkdobrev commentedon Dec 20, 2013
Hey, what's up with this one? 😄
https://github.com/blog/1721-the-ghost-of-issues-past
anpsince83 commentedon Jan 8, 2014
Another +1 for this. Seems like an essential feature for dynamic forms.
blowsie commentedon Jan 9, 2014
Also should this really be tagged as a feature and not a bug?
hkdobrev commentedon Jan 9, 2014
@blowsie It is not documented as if it's working, so it's not a bug.
elranu commentedon Feb 11, 2014
👍 Another +1 for this. Seems like an essential feature for dynamic forms.
MagRelo commentedon Mar 17, 2014
holla! +1
Rodeoclash commentedon Apr 13, 2014
+1
8 remaining items
rodyhaddad commentedon Jun 9, 2014
PRs welcome, plus fixing this should be backwards compatible 👍
caitp commentedon Jun 9, 2014
there are PRs which implement this. (#1588 for instance)
rodyhaddad commentedon Jun 9, 2014
@caitp the ones I saw are closed.
If you know of one that's still active and solves this, reference it so this issue gets closed when the PR gets merged?
caitp commentedon Jun 9, 2014
they're closed, but they could be fixed up and checked in, it's not too difficult. The issue is that we can't seem to decide whether we actually want to support them or not, because once they're expressions, people will start asking for them to be $watched and etc. It gets ugly
rodyhaddad commentedon Jun 9, 2014
We could watch them.
Constants will be unwatched anyway (e.g.
6), and bind-once can be used if you know the value never changes, and you want to optimize your application.caitp commentedon Jun 9, 2014
you know what's interesting @rodyhaddad, we don't actually consider an empty expression (
"") as a constant, so we watch those forever if they get watched. we should probably fix that.hkdobrev commentedon Jun 10, 2014
Finally I've seen some kind of meaningful discussion going on for an issue from almost two years.
rodyhaddad commentedon Jun 10, 2014
There is one issue with allowing for dynamic min/max-length.
Description: If there's a valid value in an input that respects the max-length constraint, and suddenly the max-length drops to 1, what would happen to the validation? Obviously the value is no longer valid, but do we have a way to re-run the validations and make the model value undefined?
caitp commentedon Jun 10, 2014
Make sure matsko's patch has a test for that ;)
caitp commentedon Jun 10, 2014
wait, it looks like it already got merged. is there a test for that? (this is about re-validating minlength/maxlength if their value changes --- ie when the observe listener is called. it is not about dealing with parsed expressions, but it could)
gkalpak commentedon Oct 14, 2014
This seems to have been fixed in 1.3.0 http://plnkr.co/edit/5Im8QYngPc7lGw4oaYg6?p=preview&s=tempoooo
(It's still not working on 1.2.26.)
Should this be closed ?
btford commentedon Oct 14, 2014
We'll see.
@IgorMinar, do we want to cherry-pick these changes to 1.2.x?
lgalfaso commentedon Jan 4, 2015
This is not going to be backported to 1.2, so can be closed