royB royB - 1 year ago 117
HTML Question

ngFor create 2 rows

Using Angular 2 ngFor I'm creating a table.

My problem is that

my data array
such that each element should create 2 consecutive rows in the table (Using different fields, The second row is collapsible with more data)

<tr *ngFor="let element of data; let i = index">

Problem is that
doesn't allow any attribute beside

I'm looking for something like

<template *ngFor="let element of data; let i = index">
<tr>...</tr> //row 1
<tr>...</tr> //row 2

Answer Source

That exists with slightly different syntax:

<template ngFor let-element [ngForOf]="data" let-i="index">
   <tr>...</tr> //row 1
   <tr>...</tr> //row 2
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download