I'm new here. I'm interested to know if anyone knows how to make a character counter in a textarea with typescript. Since I do not do in JavaScript and with Php. But now I'm using ionic 4, Angular 6 and TypeScript. Thanks in advance for the support.
I'm new here. I'm interested to know if anyone knows how to make a character counter in a textarea with typescript. Since I do not do in JavaScript and with Php. But now I'm using ionic 4, Angular 6 and TypeScript. Thanks in advance for the support.
To make a character counter the procedure that I use the following:
In the file of the page I add the following code:
export class HomePage{
private contador = 0 //Agrego esta linea
constructor(){}
// Agrego la siguiente función
onKey(event){
this.contador = event.target.value.length
}
}
The case of the view only adds an attribute to the input or the textarea
<textarea name="" (keyup)="onKey($event)"></textarea>
<span>{{contador}}</span>