I'm currently using a HostListener to be able to format user text at the same time that the user is typing it. For example if the user is typing a phone number I want to be able to add format just as needed. If the string is 0000 I want the text to be 000-0, if text is 0000000000 then "(801) 123 - 1234". I got the logic to do this, but I'm currently using a hostlistener to do this.
@HostListener("textChange")
public onTextChange(target): void {
this.el.text = this.phoneFormatPipe.transform(this.el.text)
}
This works, but it keeps calling itself until the max stack call limit is reached. This is obviously too slow, so my question is: how do I modify the text inside my element without tiggering the textChange event? or is there another way to accomplish this?
Thanks in advance! Happy coding!