如何在 Angular 7 中单击按钮时添加表单元素

How to add form elements on button click in Angular 7

我想重复下面的表单元素

<tr>  
                   <td class="tbl1">  
                   <mat-form-field class="demo-full-width">  
                   <input name="Label" matTooltip="Label" matInput placeholder="Label" ngModel>
                   </mat-form-field> 
                   <mat-form-field>
                   <mat-label>Input Type</mat-label>
                   <select name="inputBoxType" matNativeControl ngModel required>
                   <option value="text">Text</option>
                   <option value="number">Number</option>
                   <option value="email">Email</option>
                   </select>
                   </mat-form-field>
                   <button type="button" mat-raised-button color="accent" class="btn btn-danger" matTooltip="Add Input Box" >Add Another Input Box</button>
                   </td>  
          </tr>

单击 "Add Another Input Box" 我想重复上面的表单元素。请帮忙

看看 Angular 的 FormArray https://angular.io/api/forms/FormArray & & https://stackblitz.com/edit/angular-form-array-example(一个很好的例子)