Changing attributes of ion-input from ts file



As I said in the title, I’m trying to do something very easy. I have these input:

    <ion-input type="text" formControlName="bankEnd" maxlength ="4" id ="bankLast"></ion-input>

And I would like to change the attribute maxlength of the input to “3” from javacsript. So i wrote this:
document.getElementById("bankLast").setAttribute("maxlength", "3");

When I put a console.log:

I obtained this:

As we can see, it changed the maxlength in “3” but there is no effect in my application. Someone know why? Maybe it is because of the just below? If it is that, do you know how to fix that?

Thanks in advance.


You should use Angular property binding for this sort of things, not manipulating the DOM element yourself.


Thank you for your answer. I will check that!