以我的反应形式,我有一个被称为经验的领域。用户应该能够根据自己的需要添加尽可能多的体验(具有3个属性的对象)。要检索所有数据,当前正在使用列表(userExperience)和[(ngModel)] 还有其他方法(使用表单控件)吗?
答案 0 :(得分:0)
//Formulario
registrationForm:FormGroup = this.fb.group({
intervalos: new FormControl('', Validators.required),
addDynamicElement: this.fb.array([
])
})
get addDynamicElement() {
return this.registrationForm.get('addDynamicElement') as FormArray
}
additems(){
this.addDynamicElement.push(this.fb.control('',Validators.required))
}
en el html
<form [formGroup]="registrationForm">
<div class="group-gap" formArrayName="addDynamicElement">
<div class="center">
</div>
<div class="mb-3">
<mat-form-field class="int" appearance="outline"
*ngFor="let item of addDynamicElement.controls; let i = index">
<input matInput [formControlName]="i" placeholder="placeholder">
</mat-form-field>
</div>
<button (click)="agregar()" class="agg" [disabled]="!registrationForm.valid" mat-raised-button>Agregar</button>
</div>
</form>
帝王勇士
{{addDynamicElement.value | json}}