<textarea name="" id="" #text cols="30" (keydown)="WordCounter()" (change)="WordCounter()" rows="8" [(ngModel)]="user_text" placeholder="Type something here"></textarea>
I have created this textarea that triggers the WordCounter method when the user types in it.
WordCounter() {
this.wordCount = this.user_text.trim().split(/\s+/).length;
}
The current functionality works well, however, I noticed that when a user pastes content into the textarea, the word count does not update automatically. It only updates when I click outside the textarea. I would like the word count to update instantly as soon as the user pastes anything into the textarea.
Thank you!