Call_Back_Function Call_Back_Function - 1 year ago 261
HTML Question

Can you use a ngFor with a modulus operator in Angular 2

I'm writing out images to the web page. Every three images I would like to start a new row. Does angular 2 support this?

Answer Source

You can access the index of the iteration from the *ngFor like so:

*ngFor="let x of container; let i = index;"

you can then reference that index in an *ngIf inside of the *ngFor to display your new row:

<div *ngIf="i%3 === 0">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download