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

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

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 Report

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