Angular 页面下方的条目列表。这就像在formarray中添加2个文本框控件

Angular 页面下方的条目列表。这就像在formarray中添加2个文本框控件,angular,formarray,Angular,Formarray,嗨,我需要角4的要求,如将有2个文本框和添加按钮,一旦点击添加按钮,它应该推到页面下方的条目列表2文本框数据代码。这就像在formarray中添加两个文本框控件。在您的打字脚本中: public formArray:any=[]; ngOnInit(){ this.formArray = [{textbox1: null, textbox2: null}]; } addButtonClick(){ this.formArray.push({textbox1: null, text

嗨,我需要角4的要求,如将有2个文本框和添加按钮,一旦点击添加按钮,它应该推到页面下方的条目列表2文本框数据代码。这就像在formarray中添加两个文本框控件。

在您的打字脚本中:

public formArray:any=[];
ngOnInit(){
   this.formArray = [{textbox1: null, textbox2: null}];
}

addButtonClick(){
    this.formArray.push({textbox1: null, textbox2: null});
}
在html页面中:

<button (click)="addButtonClick()" > Add<button><br />
<div *ngFor="let obj of formArray">
   <input type="text" [(ngModel)]="obj.textbox1" />
   <input type="text" [(ngModel)]="obj.textbox2" />
</div>
添加
这是逻辑,,
希望这对你有帮助

请张贴你到目前为止做了什么