user9040429
user9040429

Reputation: 720

Displaying certain array elements in ngFor

I am fetching data from an api which is giving me table content in form of array of arrays where first array has all the column names and subsequent ones have the data. Now I want to display the first array elements in thead and rest in tbody . As far I have tried using | slice:0:1; but for setting the lastindex I am not sure what keyword will be used. Like | slice : 1 :? . Or is there any better approach to do so using native angular keywords ?

Upvotes: 1

Views: 57

Answers (1)

Teddy Sterne
Teddy Sterne

Reputation: 14219

The last parameter is optional. Not providing an end index will get a slice of the array from the start index to the end of the array. See the docs

omitted: return all items until the end.

Example:
<tr *ngFor="someArray | slice : 1">
  <!-- Details -->
</tr>

Upvotes: 4

Related Questions