Hi everyone
Today I’m struggling with an input field I want to manipulate and somehow it only works once.
I created a simple example to demonstrate it: I want to check a text that has been entered in an ion-input field. I want to check if it fulfills some requirements and if not it should be cleared. Strange: It works once when entering the first wrong letter but after that I can simple enter whatever text I want. Even though ‘checkInput()’ is fired and ‘this.input_text = “”’ is executed after every keypress it won’t clear the displayed text in the input field.
Any idea how I can achieve what I need? I tried to use ‘(ionChange)’ instead but it still didn’t work. Thanks a lot!
Thank you very much but unfortunately this doesn’t solve the problem. It’s not about the if-condition it’s about updating the input text.
Here’s an even simpler example that doesn’t work.
You must take away the banana binding on ngModel: IOW, make it [ngModel] instead. Otherwise, Angular blows away whatever you are doing in ngModelChange. This is part of why I recommend never having overlapping responsibilities.
Hi STRINIX
I already added BrowserModule befor but I’ll try onchange next time. Thanks for this.
I just thought it was better to use Angular if possible instead of plain JavaScript.