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

121
Vistas
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 Respuestas
Responde la pregunta

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 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