Dynamic input form from JSON


#1

My JSON array is look like

Array(3)
main2=
[

    0:{label: "Name", datatype: "text", lookupname: "null", order: 01"}

    1: {label: "DOB", datatype: "date", lookupname: "null", order: "02"}

   2: {label: "QRcode", datatype: "qrcode", lookupname: "null", order: "02"}

   3: {label: "Image", datatype: "image", lookupname: "null", order: "02"}

  ]

i tried to generate input form according to datatype.But i can’t include button inside the loop,No HTML tags working inside the loop only tags like ion-something working.Like to add button when the data type is barcode or qr code inside the loop

My HTML on ionic

<form>
          <ion-item *ngFor="let item of main2">
          <ion-label fixed>{{item.label}} : </ion-label>
          <ion-input type="text"  name="title" *ngIf='item.datatype == "text"'></ion-input>
          <ion-input type="text" *ngIf='item.datatype == "radio"'>Checkbox 1</ion-input>
          <ion-input type="number" *ngIf='item.datatype == "number"'></ion-input>
          <ion-datetime displayFormat="MMMM/DD/YYYY" *ngIf='item.datatype == "date"'></ion-datetime>
          <ion-input type="file"  name="title" *ngIf='item.datatype == "image"'></ion-input>
          <ion-datetime displayFormat="HH:mm" *ngIf='item.datatype == "time"'></ion-datetime>
          <ion-input type="number" *ngIf='item.datatype == "number"'></ion-input>

          <ion-input type="text"  *ngIf='item.datatype == "qrcode"' ></ion-input>
          <ion-input type="text"   *ngIf='item.datatype == "barcode"'></ion-input>

</form>

#2
 <form *ngFor="let item of main2">
    <ion-item>
      <ion-label fixed>{{item.label}} : </ion-label>
      ...
      //Option A
      <button ion-button item-right *ngIf='item.datatype == "qrcode"'>Btn</button>
    </ion-item>

    //Option B
    <button ion-item *ngIf='item.datatype == "qrcode"' (click)="test()">{{item.label}} Button</button>
  </form>