Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!