Reputation: 1218
I just started to learn angularjs so may be this question looks silly.
I have this input tag :
<input type="text" class="form-control" id="H1" name="H1" placeholder="Enter Something..." ng-trim="false" ng-model="seo.H1" required ng-minlength="5" ng-maxlength="50">
I am gonna show the count of characters of input tag in the span tag :
<span class="pull-right" style="color: gray">{{ seo.H1.length }}/50</span>
But the problem is , it starts to count from 5th character and when input gets 50 characters , span shows nothing .
how can i fix the problem ?
Upvotes: 1
Views: 1108
Reputation: 1718
ng-minlength and ng-maxlength attributes problem in here, remove the attributes ,until satisfy your ng-minlength and ng-maxlength condition it holds text box undefined
so that reason length is '0' whenever characters less than 5 and maximum up to 50.
Upvotes: 1
Reputation: 18719
The issue here is not the span itself. Everything works as expected.
Here is how it goes:
You have added ng-minlength which sets minimum lenght for the input to be valid.
You have added ng-maxlenght which sets maximum length for the input to be valid, and be able for the user to enter.
seo.H1.length
will take values from 5 to 50
Upvotes: 1