While working on a form implementation in AngularJS, I encountered a baffling behavior that has left me puzzled.
It seems that whenever I set ng-minlength=5
as an input attribute, AngularJS disconnects the value until it meets the length requirement.
This poses a problem for me as I want to display to the user the amount of content they have entered using user.lifestory.length
.
Why does AngularJS exhibit this behavior? Is there a way to prevent Angular from unbinding the value when it's invalid?
<label for="lifeStory">Life story:<input name='lifeStory' type="text" ng-model='user.lifeStory' ng-minlength='5' required></input></label>
You can check out an example showcasing this issue here: http://jsfiddle.net/J67jm/3/
To observe the behavior I mentioned, try filling in the life story field.