Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngFor - Get item from loop to call it in a function

Tags:

ngfor

angular5

I have a table containing the list of feedback. I'm trying to call the function on each looped item.

HTML File:

<ng-container *ngFor="let fd of feedbacks;let i = index">
   <tr>
     <td>{{ i + 1 }}</td>
     <td>{{ fd.feedback }}</td>
     <td><button (click)="Analyzer(fd.feedback)">Click me!</button></td>
   </tr>
     </ng-container>

Attempted action : Set each item as argument to Analyzer() function.

like image 460
Atom Avatar asked Dec 06 '25 04:12

Atom


1 Answers

What is the problem?

If you have a function defined in the .ts file

Analyzer(feedback: string) { /* .. */ }

Then what you have will work

like image 129
Bill Richards Avatar answered Dec 10 '25 14:12

Bill Richards



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!