Angular6 如何使用angular 6在单击按钮时增加文本框

Angular6 如何使用angular 6在单击按钮时增加文本框,angular6,Angular6,我试图用angular 6重复点击按钮时的文本框。 当我点击“添加”按钮添加文本框时,它会添加内容,但当我在一个字母后输入时,它会失去焦点 HTML 当添加新记录时,添加新文本框不起作用。 请建议一些解决方案或其他解决方案 <td *ngFor="let col of columns" width="{{col.width}}" [innerHtml]="rowData[col.field]"> {{rowData[col.field]}} </td>

我试图用angular 6重复点击按钮时的文本框。 当我点击“添加”按钮添加文本框时,它会添加内容,但当我在一个字母后输入时,它会失去焦点

HTML

当添加新记录时,添加新文本框不起作用。 请建议一些解决方案或其他解决方案

  <td *ngFor="let col of columns" width="{{col.width}}"  [innerHtml]="rowData[col.field]">
    {{rowData[col.field]}}
  </td>
  <td width="50">
      <button pButton type="button" label="Edit" [value]="rowData" (click)="updatePoll(rowData)"></button>
      &nbsp;&nbsp;<button pButton type="button" class="ui-button-danger" label="delete" [value]="rowData" (click)="deletePoll(rowData._id)"></button>
  </td>
      <div class="ui-g-12" *ngFor="let o of mmpollRequest.option;let index = index;trackBy:trackByFn;">
          <div class="ui-g-2">
              <label for="option">Option</label>
          </div>
          <div class="ui-g-10">
              <input pInputText id="option{{index}}" [(ngModel)]="mmpollRequest.option[index]"  />
          </div>
      </div>

  </div>
  <p-footer>
      <div class="ui-dialog-buttonpane ui-helper-clearfix">
          <button type="button" pButton icon="fa fa-close" (click)="delete()" label="Delete"></button>
          <button type="button" pButton icon="fa fa-close" (click)="increment()" label="ADD"></button>
          <button type="button" pButton icon="fa fa-check" (click)="save()" label="Save"></button>
      </div>
  </p-footer>
  constructor(private service: MmpollService, private messageService: MessageService) { }

  ngOnInit() {
    this.loading = true;
    this.mmpollRequest.sdate = new Date();
    this.mmpollRequest.edate = new Date();
    console.log(this.mmpollRequest.sdate);
    this.service.getMmpollData(this.mmpollRequest).subscribe(
      (data:any)=>{
        this.totalRows = data.data.rowCount
        this.cols = data.data.tableHeader;
        this.MmpollResponse = data.data.data;
        this.loading = false;
      }
    )
  }

  updatePoll(row) {
    this.mmpollRequest = {...row};
    console.log(row);
    this.displayDialog = true;
  }

  deletePoll(row) {
    var result = confirm("Do you want to delete this record?");
    if (result) {
      this.service.deleteRecord(row).subscribe(
        (data:any)=>{
          console.log(data);
          this.showSuccess(data.message,data.data);
          this.ngOnInit();
        }
      )
    }

  }
    increment(){
     this.mmpollRequest.option.push(1);
    }
    save(){
      console.log(this.mmpollRequest);
     }
  }