Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
How To Get Value Of Input Tag In Angular?

How To Get Value Of Input tag in typescript.

<input type="checkbox" id="demo111" (click)="chk(this)" name="schoolFactors" value="Yes" >Yes

I'm using the below code but not sure how to get & set the input box value using typescript in angular.

chk(this){
   console.log(this);
 }
about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

If you dont want to use two way data binding. You can do this.

In HTML

<form (ngSubmit)="onSubmit($event)">
   <input name="player" value="Name">
</form>

In component

onSubmit(event: any) {
   return event.target.player.value;
}
about 4 years ago · Santiago Trujillo Denunciar

0

Depends on the circumstances, another way that does not have to involve a <form> is by using ViewChild and elementRef. A very simplistic example:

HTML:

<input #cb type="checkbox" id="demo111" (change)="chk(cb.value)" name="schoolFactors" value="Yes" >Yes

Class code:

Demonstrates getting (via parameter from the HTML and directly in code) and setting the value:

  @ViewChild('cb') cb: ElementRef;

  chk(e): void {
    const nativeCb = this.cb.nativeElement as HTMLInputElement;

    console.log(e, nativeCb.value);
    nativeCb.value = 'no';
  }
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda