https://plnkr.co/edit/umL80bh0WKr8aPEueCxZ?p=preview
You can create pipe to get pairs values:
@Pipe({ name: 'pairs' })
export class PairsPipe implements PipeTransform {
transform(array) {
return array.reduce((result, item, index) => (
index % 2 ? result : [...result, [item, array[index + 1]]]
), []);
}
}
add pipe to Module:
@NgModule({
imports: [ BrowserModule ],
declarations: [ App , PairsPipe],
bootstrap: [ App ]
})
and use in *ngFor:
<tr *ngFor="let item of data | pairs">
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…