Search code examples
jsonangularangular6angular-forms

store input field attributes id, name, type in angular 6


I want to store & send the input field attributes id, name, type & value; to my server. I am able to store the "name: value," in json format & send to server.

I want to send the input data in below format:

{ 
   "iEntityId":2,
   "data":[
      {
         "id":2,
         "value":"some name",
         "name":"sSupplierName",
         "type":0
      },
      {
         "id":3,
         "value":"some code",
         "name":"sSupplierCode",
         "type":0
      }
   ]
}

Below is my input field:

<input [type]="q.sFieldType" 
       [formControlName]="q.sFieldName" 
       [id]="q.sFieldName" 
       class="form-control m-input">

Solution

  • I have got the solution for this, we just need set a json object and then input the dynamic fields that are used in the input attributes.