I'm trying to make new row using *ngFor:<div class="row">
<div class="col-lg-3" *ngFor="let user of users">{{user.username}}</div>
</div>
And then, if col div`s > 4, i need to create new row. How can i do it?
I'm trying to make new row using *ngFor:<div class="row">
<div class="col-lg-3" *ngFor="let user of users">{{user.username}}</div>
</div>
And then, if col div`s > 4, i need to create new row. How can i do it?
If you want to create div elements of row class using ngFor, then put the directive in that div.
ngFor will add content including the div it is written in
So in your example, it will be
HTML
<div class="row" *ngFor="let row of rows;let i = index">
<div class="col" *ngFor="let col of row;let j = index">
Row {{i}} Col {{ j }}
</div>
</div>
TS
export class AppComponent {
public rows = [
[1,1,1,1],
[1,1],
[1,1,1]
]
}
Working example : stackblitz.com