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

185
Views
Embedding dynamic variable in ngFor in Angular 11

I'm getting a syntax error when I write this code...

<tbody>
   <tr *ngFor="let incident of incidents | paginate: { itemsPerPage: itemsPerPage, currentPage: page }">
    <td>{{ incident.name }}</td>
    <td>{{ incident.type }}</td>
    <td>{{ incident.str }}</td>
    <td>{{ incident.mtdna }}</td>
    <td>{{ incident.ystr }}</td>
    <td>{{ incident.xstr }}</td>
    <td>{{ incident.snps }}</td>
    <td>
      <button type="submit" (click)="editRecord({{incident.id}})" class="btn btn-primary float-start">
      Edit {{ incident.id }}
      </button>
    </td>
   </tr>
</tbody>

The issue is the (click)="editRecord({{incident.id}})" part of this code.

Angular 11 is not allowing me to embed the id into the editRecord() method call.

If I write (click)="editRecord(1), then the error goes away.

My question is, how do I embed the id into the editRecord method call?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is no need for {{ }}, you can just avoid that becase (click)="expects variable or method calls or executable code"

<button type="submit" (click)="editRecord(incident.id)" class="btn btn-primary float-start">
      Edit {{ incident.id }}
      </button>
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!