Search code examples
typescriptiterationsliceangular8ngfor

How to show some content after each 5 iteration of ngFor in angular 8 project?


Gues someone can help me. My aim is to show some content after each 5 iterations of the ngFor. I tried to used the slice but cannot actually control what happen after the iterations. Need help please


Solution

  • You can do something similar:

    <div *ngFor="let element of array; let i = index">
    {{ element }}
    <div *ngIf="i > 0 && (i+1)%5 === 0">Each 5</div>