When the user chang...">

Ionic text area input event

I am using Ionic3 and have:

        <ion-textarea (change)="reviewChange()"></ion-textarea>

      

When the user changes input and blurs the focus out of the text area, the function is reviewChange()

triggered as expected.

Question

Is it possible to add an event equivalent ion-searchbar

ionInput

? that is, when the user enters text, an event is fired for each key pressed.

Background

I am trying to track how many characters a user has left. eg.

500 characters left

      

To do this, I need to track every key stroke. Is there a better way or some automated way to do this?

+3


source to share


2 answers


An easier way would be to bind the text area to a property from the component

<ion-textarea maxlength="500" [(ngModel)]="myText"></ion-textarea>

      



And below that area of ​​text, you can display the characters remaining like this:

<span>{{ 500 - myText.length }} characters left</span>

      

+6


source


You can just try event (input). It runs for every key entry.



     <ion-textarea [(ngModel)]="text" (input)="reviewChange()"></ion-textarea>

      

+1


source







All Articles