Issue
How to make a responsive grid in ionic angular and ngfor? Just like here enter image description here
My grid template:
<ion-grid>
<ion-row>
<ion-col>
<ion-item *ngFor="let prod of displayedList" class="item-entry" detail routerLink="/tabs/tab1/prod-detail/{{ prod.id }}">
<ion-thumbnail>
<ion-img [src]="prod.images[0].src" alt="{{ prod.name }}"></ion-img>
</ion-thumbnail>
<ion-label>
<h3 class="item-name">{{ prod.name }}</h3>
<ion-text>
<p class="price">{{ prod.price | currency:"GBP" }}</p>
</ion-text>
</ion-label>
</ion-item>
</ion-col>
</ion-row>
</ion-grid>
I've tried to suggest this grid, but I don't know how to display it in the ngFor loop.
<ion-grid>
<ion-row>
<ion-col>1</ion-col>
<ion-col>2</ion-col>
<ion-col>3</ion-col>
</ion-row>
</ion-grid>
Solution
you could try adding a size to your ion-col and putting *ngFor inside ion-col itself. An example could be:
<ion-col sizeXs="4" *ngFor="let element of elements">
<ion-item>...</ion-item>
</ion-col>
As you can see I used size 4 so that 3 columns (12 is the max so 12/4 = 3) can fit inside 1 row. Hope it helps!
Answered By - Alessandro Di Bartolomeo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.