【发布时间】:2018-11-01 09:35:25
【问题描述】:
不适用于 @ViewChildren 父级和多个子级的 Angular 验证。
在父组件中使用了多个子组件
@ViewChildren('aaa') pList:QueryList<PComponent>;
能够获取子组件值。
但无法验证。父窗体中的保存按钮。如果我们检查子字段值是否有效,则返回 false 不适用。
let index1 = 0 ;
@ViewChildren('pDirection') pList:QueryList<PComponent>;
pFormArray.controls.forEach(ele => {
let pList = this.pList.toArray()[index1];
let stationList = pList ["portRotationForm"]["controls"]["stationFormArray"]["controls"];
stationList.forEach(elements => {
if (elements.controls["countryName"].invalid ) {
validForm = false;
}
});
});
【问题讨论】:
标签: angular angular-reactive-forms