我在计算Angular 2中的ngFor Loop时遇到了问题。我试图开发一个有3列和动态数量的行的网格。我想遍历我的数组,并从左到右添加元素,每三个元素都应该跳到下一行。我使用Ionic Framework 2.0。在ngFor-Angular 2中计数
我的代码如下所示:
<ion-row *ngFor="#m of movies; #i = index" (click)="movieTapped(m)">
<ion-col width-33>
<div class="row responsive-md">
<img [src]="m.Poster" width="100%" />
{{m.Title}} <br>
Rating: {{m.imdbRating}}<br>
Rated: {{m.Rated}}<br>
Released: {{m.Year}}<br>
</div>
</ion-col>
<ion-col width-33>
<div class="row responsive-md">
<img [src]="m.Poster" width="100%" />
</div>
</ion-col>
<ion-col width-33>
<div class="row responsive-md">
<img [src]="m.Poster" width="100%" />
</div>
</ion-col>
</ion-row>
希望你能帮助我。
干杯!
非常感谢你!这正是我正在寻找的 – Jonas
这正是我所需要的。好东西。 –