angular - Angular FormArray 未显示其任何 formControl
问题描述
我的 FormArray(反应形式)在前端没有显示任何内容,我在控制台中也没有出现任何错误,而如果我通过 formarray 登录,我可以看到它的值
我被困了将近两天:(我看过十几个关于反应形式的formarrays的视频,但没有一个对我有用
我的 .ts
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>
解决方案
推荐阅读
- node.js - 在使用加密进行解密时,使用 Node.js 得到错误的解密错误
- seaborn - Seaborn.distplot 具有概率而不是概率密度函数
- java - 运行 dockerised 应用程序时连接到本地主机被拒绝
- python - 带有 TypeError 的 scikit-learn 管道预处理:拟合时在“str”和“float”的实例之间不支持“<”
- android-management-api - 更改设备上的策略名称不会从设备中删除旧的策略应用
- javascript - 如何在我的 php 代码中使用 Javascript 变量,该变量包含在我的脚本标签中
- typescript - 如何在没有额外查找的情况下区分字符串值和字符串枚举?
- android-studio - 如何从其标签访问图像?
- android - 如何在android中的不同点击上重定向不同部分的活动
- angular - 启用 Angular 9 Ivy 会引发错误