InterviewSolution
Saved Bookmarks
| 1. |
How would you find out the index of the current element in the ngFor loop? |
|
Answer» We can simply use the index keyword. For example, in the following code, all we are doing is add let i = index in the ngFor expression and we can then access the index of the CURRENT ELEMENT in the loop using the variable name - i. <tr *ngFor="let POLICY of POLICIES; let i = index"> <td>Index: {{i}}</td> <td>{{policy.name}}</td> </tr> |
|