Limit NgFor

-1

I would like to know how do I limit my NgFor to spend only 6 times ??

In my .TS I imported this module below ...

import { NgForOf } from '@angular/common';

I tried to use it this way, but it did not work ...

 <div *ngFor="let concessionaria of concessionarias; index as i">
    <vw-component-dealers [concessionaria]="concessionaria" ></vw-component-dealers>        
</div>
    
asked by anonymous 17.04.2018 / 14:00

1 answer

2

You can user the slice with ngFor to determine the positions of the list you need, a reference: link .

<div *ngFor="let concessionaria of concessionarias | slice:0:5 ; index as i"> <vw-component-dealers [concessionaria]="concessionaria" ></vw-component-dealers></div>

In the above case it goes through positions 0 through 5 of the list.

    
17.04.2018 / 14:07