Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda