I want to set the maxlength of an input via AngularJS and when the user have reached the maximum characters then no new characters should be added to the input.
I have an input which ng-model is selecteddata.Type.Value
The max character value is stored in selecteddata.Type.MaxLength
I've added the html5 maxlength attribute as below:
<input type="text" ng-model="selecteddata.Type.Value" maxlength="{{selecteddata.Type.MaxLength}}" />
This works as I want to, when the user reach the maximum characters it's not possible to add new but it doesn't set the selecteddata.Type.Value..
Why doesn't this work? Is there a AngularJS way of doing this? I've read about ngMaxlength but it doesn't behave as I want. Do I need to write a custom directive to make this work? Any suggestions?