本文整理汇总了TypeScript中@angular/forms.FormArray.setValidators方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormArray.setValidators方法的具体用法?TypeScript FormArray.setValidators怎么用?TypeScript FormArray.setValidators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.FormArray
的用法示例。
在下文中一共展示了FormArray.setValidators方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngOnInit
public ngOnInit() {
const collection: any[] = this.csConfig[this.csDefinition.propertyName];
if (this.csDefinition.keyPropertyName) {
this.collectionForms.setValidators(uniqueKey(this.csDefinition.keyPropertyName));
}
collection.forEach((value, i) => {
this.collectionForms.setControl(i, this.formBuilder.group({}));
});
this.parentForm.setControl(this.csDefinition.propertyName, this.collectionForms);
this.collection = collection;
}
示例2: setupForm
private setupForm() {
let collection: string[] = this.csConfig[this.csDefinition.propertyName];
if (!collection) {
collection = new Array<string>();
}
collection.forEach((value, i) => {
this.collectionForms.setControl(i, this.buildControl(value));
});
this.parentForm.setControl(this.csDefinition.propertyName, this.collectionForms);
this.collection = collection;
if (this.csDefinition.validationDefinition && !this.csDefinition.validationDefinition.allowDuplicates) {
this.collectionForms.setValidators(uniqueItem());
}
}