Angular 角度FormArray不显示其任何formControl
我的FormArray(反应表单)在前端没有显示任何内容,我在控制台中也没有收到任何错误,而如果我通过FormArray登录,我可以看到它的值 我被困在这里面已经快两天了:(我已经看了十几个关于Formarray的视频,都是被动的形式,但没有一个对我有用 我的Angular 角度FormArray不显示其任何formControl,angular,angular-material,angular-reactive-forms,formarray,Angular,Angular Material,Angular Reactive Forms,Formarray,我的FormArray(反应表单)在前端没有显示任何内容,我在控制台中也没有收到任何错误,而如果我通过FormArray登录,我可以看到它的值 我被困在这里面已经快两天了:(我已经看了十几个关于Formarray的视频,都是被动的形式,但没有一个对我有用 我的 this.formGroupMail = this.fb.group({ email: this.fb.array([this.addEmailGroup()]) }); // this loops the
this.formGroupMail = this.fb.group({
email: this.fb.array([this.addEmailGroup()])
});
// this loops the mails coming from the service
this.mailForm = this.formGroupMail.get('email') as FormArray;
if (this.route.snapshot.data['value'].mails !== undefined) {
for (const c of this.route.snapshot.data['value'].mails) {
this.mailForm.push(this.fb.group({descripcion: new FormControl(c.descripcion),
isCc: new FormControl(c.isCc),
isCco: new FormControl(c.isCco)}));
}
}
addEmailGroup() {
return this.fb.group({
descripcion: [],
isCc: [],
isCco: []
});
}
get mailArray(){
return this.formGroupMail.get('email') as FormArray;
}
我的html:
<form [formGroup]="formGroupMail">
<ng-component formArrayName="email">
<div *ngFor="let group of mailArray.controls; let i = index" [formGroupName]="i">
<div fxLayout="row" fxLayoutGap="0.7rem">
<mat-label>E-mail</mat-label>
<input formControlName="descripcion" type="text" class="form-control"
placeholder="Email"/>
</div>
</div>
</ng-component>
</form>
电子邮件