<textarea name="" id="" #text cols="30" (keydown)="Counter()" (change)="Counter()" rows="8" [(ngModel)]="user_text" placeholder="Please write"></textarea>
I have this textarea i want to call counter method when the user types in the textarea
wordCounter() {
this.count= this.user_text.trim().split(/\s+/).length;
}
this is working but when i paste anything in textarea then value not gets updated and value only gets updated when i click on window. I want count should get updated as soon user paste anything in textarea
Thanks
Since your using Angular I would recommend using the formbuilder instead of NgModule and subscribe to the events there.
Checkout an example here: https://stackblitz.com/edit/angular-ivy-rwjwd5?file=src/app/app.component.ts
and Documentation here: https://angular.io/api/forms/FormBuilder