Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count characters in keyup in angular 6

how do you count characters including space in keyup event in angular 6?

import { Component } from '@angular/core';
@Component({
  selector: 'app-loop-back',
  template: `
    <input #box (keyup)="0">
    <p>{{box.value}}</p>
  `
})
export class LoopbackComponent { }
like image 642
Kevin Daniel Avatar asked Feb 04 '26 23:02

Kevin Daniel


1 Answers

You can count character by box.value.length or box.value?.length

? after the property will check for undefined..

like image 108
Kousher Alam Avatar answered Feb 06 '26 14:02

Kousher Alam