Call_Back_Function Call_Back_Function - 2 months ago 40
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

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">