Dear all,
I hope you are doing well. While creating one component using Angular 6 and ASP .Net MVC I am facing one problem.
I have one one array and I want to print it in a table so for I am using ngFor loop.
I want to call a function for every row. How can I do that?
What I have tried is :-
- <table class="table">
- <tr>
- <th>#</th>
- <th>Game</th>
- <th>Platform</th>
- <th>Release</th>
- </tr>
- <tr *ngFor="let game of games; let i = index; trackBy:GameName(i)">
- <td>{{i + 1}}</td>
- <td>{{game.game}}</td>
- <td>{{game.platform}}</td>
- <td>{{game.release}}</td>
- </tr>
- </table>
in ts :-
- GameName(index){
- alert(index);
- }
If I run above code then it returns undefined for infinite time. I want to cal that function till only length of array.
Please let me know if you have any suggestions.
Thanking you in advance.