如何使用角度输入手动添加多个json键值对?

时间:2019-03-25 07:20:18

标签: angular

我必须像使用视图输入一样创建动态对象 (用户可以添加多个键和值) 例如:“ data”:[{“ Terms”:“ {” metaDataKey“:[” metaData“,” metaData“]},               {“ hero:[” value1“,” Value2“]}”}]

 <tr>
                        <td>
                            <mat-form-field class="example-full-width">
                                <input [(ngModel)]="metaDataKey" matInput formControlName="metaDataKey"
                                       autocomplete="off"
                                       placeholder="Meta Data Key">
                            </mat-form-field>
                        </td>

                        <td>
                            <mat-form-field class="example-full-width">
                                <mat-chip-list #metaDataChipList>
                                    <mat-chip *ngFor="let term of metaData" [selectable]="selectable"
                                              [removable]="removable" (removed)="remove(term, metaData)">
                                        {{term}}
                                        <mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
                                    </mat-chip>
                                    <input name="metaData" placeholder="Meta Data"
                                           [matChipInputFor]="metaDataChipList"
                                           [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
                                           [matChipInputAddOnBlur]="addOnBlur"
                                           (matChipInputTokenEnd)="add($event)">
                                </mat-chip-list>
                            </mat-form-field>
                        </td></tr>

0 个答案:

没有答案