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

313
Views
How to pass parameters to a typescript function from html?

I am fetching my users in the form of a JSONArray and I want to show the data of each user when clicked on their names. but I am not able to pass the user.id into the function.

<ng-container *ngFor = "let user of users" >
        <button (onclick)="getdata(user.id)" mat-raised-button color="primary">{{user.name}}</button>
      </ng-container>
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Its angular use (click) instead of (onclick)

<ng-container *ngFor="let user of users">
  <button (click)="getdata(user.id)" mat-raised-button color="primary">
    {{ user.name }}
  </button>
</ng-container>
getdata(id) {
  console.log(id);
}
about 4 years ago · Juan Pablo Isaza Report

0

Can you please try the same with using only click() instead on onclick()

<ng-container *ngFor = "let user of users" >
    <button (click)="getdata(user.id)" mat-raised-button color="primary">{{user.name}}</button>
  </ng-container>
about 4 years ago · Juan Pablo Isaza Report

0

try this

<ng-container *ngFor = "let user of users" >
    <button (click)="getdata(user.id)" mat-raised-button color="primary">{{user.name}}</button>
</ng-container>
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!