Changing attributes of ion-input from ts file

Hello,

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

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

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:
console.log(document.getElementById("bankLast"));

I obtained this:
image

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.

2 Likes

Thank you for your answer. I will check that!