存储输入字段属性 id, name, type in angular 6

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

我想存储和发送输入字段属性id、名称、类型和值;到我的服务器。 我能够以 json 格式存储 "name: value," 并发送到服务器。

我想发送以下格式的输入数据:

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

下面是我的输入框:

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

我已经找到了解决方案,我们只需要设置一个 json 对象,然后输入在输入属性中使用的动态字段。