本文整理汇总了TypeScript中@angular/forms.FormGroup.addControl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormGroup.addControl方法的具体用法?TypeScript FormGroup.addControl怎么用?TypeScript FormGroup.addControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.FormGroup
的用法示例。
在下文中一共展示了FormGroup.addControl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngOnInit
ngOnInit() {
this.EditForm = this._fb.group({});
const title = new FormControl();
title.setValidators([Validators.required]);
this.EditForm.addControl('title', title);
const subtitle = new FormControl();
subtitle.setValidators([Validators.required]);
this.EditForm.addControl('subtitle', subtitle);
const detail = new FormControl();
detail.setValidators([Validators.required]);
this.EditForm.addControl('detail', detail);
const tag = new FormControl();
tag.setValidators([Validators.required]);
this.EditForm.addControl('tag', tag);
}
示例2: setParagraph
/**
* Called by the template when a paragraph is clicked in single paragraph mode.
* Behaves like a radio-button
*
* @param {ParagraphToChoose} paragraph
*/
public setParagraph(paragraph: ParagraphToChoose): void {
this.contentForm.value.selectedParagraphs.forEach(para => {
this.contentForm.removeControl('text_' + para.paragraphNo);
});
this.contentForm.addControl(
'text_' + paragraph.paragraphNo,
new FormControl(paragraph.rawHtml, Validators.required)
);
this.contentForm.patchValue({
selectedParagraphs: [paragraph]
});
}
示例3:
Object.keys(controls).forEach((controlName, idx) => {
let controlModel = models[idx];
if (formModel instanceof DynamicFormGroupModel) {
formModel.insert(index, controlModel);
} else {
(formModel as DynamicFormControlModel[]).splice(index, 0, controlModel);
}
formGroup.addControl(controlName, controls[controlName]);
});
示例4: ngOnInit
public ngOnInit() {
this.control = new FormControl(
"",
Validators.compose([
Validators.required,
this.keyFormatValidator,
this.keyTypeValidator.bind(this),
this.originMatchValidator.bind(this),
])
);
this.form.addControl("key", this.control);
}
示例5: FormControl
.forEach( question => form.addControl(question.key, new FormControl('')));
示例6: FormControl
this.formConfig.forEach(controlConfig => {
this.form.addControl(controlConfig.name, new FormControl());
this.buildControl(controlConfig);
});
示例7: ngOnInit
ngOnInit() {
this.form = new FormGroup({});
this.form.addControl('quantity', new FormControl(1, [this.validateQuantity]));
}
示例8: ngOnInit
/**
* Component being initialized.
*/
ngOnInit(): void {
// Always set confirmdatasaved to 1. Sending the data means the user accepted.
this.form.addControl('confirmdatasaved', this.fb.control(1));
}
示例9:
prop.propertyMap.forEach(name => {
const control = fb.control(0)
control.setParent(this.boxModel)
this.boxModel.addControl(name, control)
})
示例10: FormGroup
const questionOne = new FormGroup({
key: new FormGroup({
name: new FormControl('boolean_key'),
type: new FormControl('boolean')
}),
label: new FormControl('question label'),
controlType: new FormControl('Toggle'),
id: new FormControl('fake_id'),
index: new FormControl(0),
options: new FormControl([]),
conditionalQuestions: new FormControl([]),
expandable: new FormControl(false)
});
const form = new FormGroup({});
form.addControl('fake_id', questionOne);
const screenerState: fromScreener.State = {
loading: false,
form: form,
error: '',
selectedConstantQuestion: 'fake_id',
selectedConditionalQuestion: undefined,
keys: [
{name: 'boolean_key', type: 'boolean'},
{name: 'integer_key', type: 'integer'}
],
created: 0
};