Input maxLength


How can i set a dynamic maxLength to a <ion-input> ?
I tryed it with maxlengt=_maxLength which didn’t work but maxlength=10 works.
Also tryed [attr.maxlength]= and [maxlength]= both don’t worked for me…

Isn’t it possible to set the normal maxlength of the base input?
Or is there a work around which works with objects?



Use Validators, i.e. :

this.myForm ={
      my_field: ['', [

Then replace dynamically in your code. That should work.


Oh crap! You meant in your view right?

Why not then try this:


Where myMaxLength is defined somewhere in your TS?


yeah i meant in my view :stuck_out_tongue:
so i tryed it before but tryed it again now and still not working with

Seems like its just ignored somehow if its not a fix value…

Looks like i need some validating code