下面的代码基于偶数和奇数创建两列。我将如何更改,而不是在第1列中显示前8个结果,在第2列中显示其余的结果,而不是偶数和奇数?
<div *ngFor="let year of userYear; let i = index">
<div *ngIf='i%2 === 0' class="float-left left-column push-left"><span>{{year}}</span></div>
<div *ngIf='i%2 !== 0' class="float-left right-column"><span>{{year}}</span></div>
</div>
答案 0 :(得分:1)
只需将i%2 === 0
更改为i < 8
,将i%2 !== 0
更改为i >= 8
:
<div *ngFor="let year of userYear; let i = index">
<div *ngIf='i < 8' class="float-left left-column push-left"><span>{{year}}</span></div>
<div *ngIf='i >= 8' class="float-left right-column"><span>{{year}}</span></div>
</div>