You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I'm trying to use AsYouType formatter in order to format user input in my Angular 2 application.
I'm creating an instance of asYouType with the input component and I can feed new numbers to it by listening to the keyup event of the input element: input.value = formatter.input(event.key); and it works great. But, when I press backspace it continues to render previous value, because it doesn't know about removed character. So, how do I tell it to actually remove one character?
The only workaround I've found so far is to create new instance of the formatter on each keyup event and to feed entire input value to it. It works flawlessly, but it's terrible from the design perspective and probably performance (creating a new instance of the object and calling a function on it is probably a serious overkill).
How do I use it correctly and at the same time achieve better design and performance?
Thanks!
The text was updated successfully, but these errors were encountered:
You guessed right – just create a new instance every time.
I didn't measure the performance penalty: perhaps it could be .reset() somehow, but I didn't check that.
This looks like a serious design flaw, why do you need an input() function capable of accepting numbers one by one, when you actually passing entire string to it all the time?
Hello!
Thank you for this great module!
However, I'm trying to use AsYouType formatter in order to format user input in my Angular 2 application.
I'm creating an instance of
asYouType
with the input component and I can feed new numbers to it by listening to thekeyup
event of theinput
element:input.value = formatter.input(event.key);
and it works great. But, when I press backspace it continues to render previous value, because it doesn't know about removed character. So, how do I tell it to actually remove one character?The only workaround I've found so far is to create new instance of the formatter on each
keyup
event and to feed entire input value to it. It works flawlessly, but it's terrible from the design perspective and probably performance (creating a new instance of the object and calling a function on it is probably a serious overkill).How do I use it correctly and at the same time achieve better design and performance?
Thanks!
The text was updated successfully, but these errors were encountered: