Learner Learner - 1 year ago 46
AngularJS Question

trailing zeros in textbox deletes values sometime (Not reproducible always)

I have a textbox, in angular/html5 with type as tel.

Its telephone number and I am afraid it deletes the value when typed fastly especially when we type the trailing zero, for example, 07100000, it deletes whole value. What is the reason?

It never happens again though, but only at certain time I could replicate it.

Earlier I had type = text, but now I changed to type = tel. Is there any other way to build it robustly such that it wont delete values no matter how fast user types and with trailing zeros.


It is possible that when you're working on a device with heavy memory usage, the ng-model is not updated correctly if you type too fast. A good solution is to add

ng-model-options="{ debounce: 1000 }"

to your input fields that are binded with ng-model. This will make your input fields update your model 1 second (can be customized) after you've typed something. This improves your performance and lessens your memory usage.

There are other options aswell, see documentation on Angular ngModelOptions