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

123
Visualizações
Unable to get input using ngModel

I'm trying to get the input from some textboxes, but for some reason in my first textbox i'm getting the input without any problem. But on the second one i'm not getting any value from it even if i type something inside the textbox.

My html elements (the name input tag works):

<div class="form-group">
            <label class="control-label">School name</label>
            <input placeholder="Name" type="email" class="form-control" name="name" [(ngModel)]="name"
                required>
        </div>
        
        <div class="form-group">
            <label for="exampleFormControlInput1">School Address *</label>
            <input placeholder="Address" type="email" class="form-control" name="sh_address" [(ngModel)]="sh_address"
                required>
        </div>

My code (this is called when the form is submitted):

public name: string = "";
public sh_address: string = "";

validateNewSchoolData() {

    console.log(this.sh_address)
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I tried your code in a new Angular Version 12 project. Your code works. Do you have imported the FormsModule?

  imports: [
    FormsModule,
    ...
  ],

Can you define the angular version you use or create a running code snippet to test?

I checked the two values by a button onClick event and console.log:

buttonClick() {
  console.log(this.name, this.sh_address);
}

https://stackblitz.com/edit/angular-ivy-v51ahs

Greetings!

about 4 years ago · Juan Pablo Isaza 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