-2
object = [{id='1',name="cosette"},{id='2',name="koko"},{id='3',name="krysto"}]

i want to display the object in row and columns dynamically

want i want to get i tried to do

<ion-row *ngFor="let data of object">
<ion-col > {{data.id}}</ion-col>
<ion-col> {{data.name}}</ion-col>
</ion-row>

i don't want to use name and id i need to let it be dynamic. any help ?

cosette
  • 33
  • 7

2 Answers2

1

From Angular 6.1 you can use a KeyValue pipe.

<ion-row *ngFor="let o of object">
    <ion-col *ngFor="let data of o | keyvalue"> {{data.value}}</ion-col>
</ion-row>

enter image description here StackBlitz here.

mcjmzn
  • 353
  • 6
  • 13
-2

Your Json is not a in good format it should be

object = [{'id':'1','name':"cosette"},{'id':'2',name:"koko"},{'id':'3','name':"krysto"}];

Please take at this stackblitz

BELLIL
  • 739
  • 10
  • 23
  • 1
    OP says they don't want to use explicitly use properties `id` and `name. Your stackblitz explicitly uses those properties. Therefore, really not an answer. – The Head Rush Feb 24 '20 at 21:39
  • 1
    OP says also "i need to let it be dynamic", it means that he doesn't want to use static values in html, i think you did not get the question, let's see if OP finds my answer helpful or not – BELLIL Feb 24 '20 at 21:51