'how to trigger function if customer just starts typing [closed]
I've been looking around, and I can't find an answer to this. I would like to have a mat dialog box open when a customer just starts typing. No focus nor input. Just starts typing. I'm sure the answer is simple, but I just can't find it. Thanks in advance!
Solution 1:[1]
A simple host listener should do the trick:
@HostListener('window:keyup', ['$event'])
keyEvent(event: KeyboardEvent) {
this.openDialog();
}
Where openDialog is the function that triggers your MatDialog.
Solution 2:[2]
You can use in your input this:
<input (change)="doSomething($event.target.value)">
Using (change) event you can do something when start typing.
Let me know it worked for you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bamoure |
| Solution 2 | Jose Vicente |
