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.
Hello,
I have stumbled upon an issue with ng-maxlength (same with ng-minlength) attribute of the text input (and textarea). After adding the validation and setting programmatically value of the input, the ng-change expression is being evaluated, while according to the docs, it should be executed only after user interaction.
I'm not 100% sure, but the issue occurs when the value being set for the input is valid.
Live example here: http://plnkr.co/edit/Fbbfm3vsYsAFmGVAL0Q8?p=preview
I think this is actually correct, the documentation error is just that... a documentation error. It's the only sane way we can do it consistently for everything that uses ngModel --- I would consider this a non-bug
Ok, now it only happens when the validator returns false. Very inconsistent. I don't think this is right, as the model hasn't changed. Maybe ngChange never took inital scope values into account.
ngChange just registers a listener to ngModel's array of listeners which are notified when the model changes. It has no machinery for caring whether the value actually changed or not, that's ngModel's responsibility.
Ah, okay now I see it. ngChange fires because the model is set to undefined, because it's invalid. So it's working as intended. If you want invalid modelValues on $scope, you can use allowInvalid in ngModelOptions.
Activity
Narretz commentedon Sep 10, 2014
This has been fixed since 1.3.0-rc.1
dankraw commentedon Sep 10, 2014
@Narretz Unfortunately, it's not fixed: http://plnkr.co/edit/7a1jEb2y2mdfODVeMmQv?p=preview
I've changed the validator, so the input's value is now invalid. Same with
ng-minlength.caitp commentedon Sep 10, 2014
I think this is actually correct, the documentation error is just that... a documentation error. It's the only sane way we can do it consistently for everything that uses ngModel --- I would consider this a non-bug
Narretz commentedon Sep 10, 2014
Ok, now it only happens when the validator returns false. Very inconsistent. I don't think this is right, as the model hasn't changed. Maybe ngChange never took inital scope values into account.
caitp commentedon Sep 10, 2014
ngChange just registers a listener to ngModel's array of listeners which are notified when the model changes. It has no machinery for caring whether the value actually changed or not, that's ngModel's responsibility.
Narretz commentedon Sep 10, 2014
Ah, okay now I see it. ngChange fires because the model is set to undefined, because it's invalid. So it's working as intended. If you want invalid modelValues on $scope, you can use allowInvalid in ngModelOptions.
dankraw commentedon Sep 10, 2014
OK, so rc1 is fine as well as the docs. ;) Thanks for the explanation.