本文整理汇总了TypeScript中@angular/forms.FormGroup.setControl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormGroup.setControl方法的具体用法?TypeScript FormGroup.setControl怎么用?TypeScript FormGroup.setControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.FormGroup
的用法示例。
在下文中一共展示了FormGroup.setControl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setObjectives
setObjectives() {
/* const objectives = this.board.selectObjectives
.map(o => { return { organizationId: o.organization.id, objective: o.objective }}); */
const objectiveFGs = this.board.selectObjectives.map(o => this.fb.group(o));
const objectiveFormArray = this.fb.array(objectiveFGs);
this.form.setControl('selectObjectives', objectiveFormArray);
}
示例2: 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;
}
示例3: 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());
}
}
示例4: populateClubsForm
private populateClubsForm(clubs): void {
const newClubsArray: FormArray = this.fb.array([]);
this.clubs.map((club: Club) => {
const clubControl: FormControl = this.fb.control(club);
const nameControl: FormControl = this.fb.control(club.clubName, [
Validators.required,
Validators.minLength(3),
Validators.maxLength(250),
this.existingClubName()
]);
const group: FormGroup = this.fb.group({
name: nameControl,
club: clubControl
});
newClubsArray.push(group);
});
this.clubsForm.setControl('clubs', newClubsArray);
}