0
I made a table that searches 100 items from within my API, now I need to number the rows in that table. For that, I created a variable number called columns and made a FOR:
colunas: number;
linhasTeste(){
for(let i = 1 ; i < 101; i++){
this.colunas = i;
console.log('linhas:', this.colunas);
}
}
The result of my console.log returning a counter from 1 to 100 that was expected, but in my column rows, only the last result of the loop appears.
<tbody>
<tr *ngFor="let pokemon of pokemons[0]">
<td>
{{colunas}}
</td>
<td>
{{pokemon.name}}
</td>
<td>
{{pokemon.url}}
</td>
</tr>
<tr>
</tbody>
How can I display the numbers in ascending order in my table from 1 to 100? Thank you!
You don’t need that, the ngFor already has an index to be used in HTML, would just do
ngFor="let pokemon of pokemons[0]"; let idx = index
and useidx
in place of columns.– LeAndrade