Character Counter with TypesScript

0

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.

    
asked by Argenis Cabello 30.10.2018 в 15:09
source

1 answer

0

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>
    
answered by 01.11.2018 / 23:10
source