本文整理汇总了TypeScript中@angular/forms.FormGroup.removeControl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormGroup.removeControl方法的具体用法?TypeScript FormGroup.removeControl怎么用?TypeScript FormGroup.removeControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/forms.FormGroup
的用法示例。
在下文中一共展示了FormGroup.removeControl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: removeFormGroupControl
removeFormGroupControl(index: number, formGroup: FormGroup, formModel: DynamicFormModel): void {
if (formModel instanceof DynamicFormGroupModel) {
formGroup.removeControl(formModel.get(index).id);
formModel.remove(index);
} else {
formGroup.removeControl(formModel[index].id);
(formModel as DynamicFormControlModel[]).splice(index, 1);
}
}
示例2: toggleParagraph
/**
* Called by the template when a paragraph is clicked in multiple paragraph mode.
* Behaves like a checkbox
*
* @param {ParagraphToChoose} paragraph
*/
public toggleParagraph(paragraph: ParagraphToChoose): void {
let newParagraphs: ParagraphToChoose[];
const oldSelected: ParagraphToChoose[] = this.contentForm.value.selectedParagraphs;
if (this.isParagraphSelected(paragraph)) {
newParagraphs = oldSelected.filter(para => para.paragraphNo !== paragraph.paragraphNo);
this.contentForm.patchValue({
selectedParagraphs: newParagraphs
});
this.contentForm.removeControl('text_' + paragraph.paragraphNo);
} else {
newParagraphs = Object.assign([], oldSelected);
newParagraphs.push(paragraph);
newParagraphs.sort(
(para1: ParagraphToChoose, para2: ParagraphToChoose): number => {
if (para1.paragraphNo < para2.paragraphNo) {
return -1;
} else if (para1.paragraphNo > para2.paragraphNo) {
return 1;
} else {
return 0;
}
}
);
this.contentForm.addControl(
'text_' + paragraph.paragraphNo,
new FormControl(paragraph.rawHtml, Validators.required)
);
this.contentForm.patchValue({
selectedParagraphs: newParagraphs
});
}
}
示例3:
.forEach(question => form.removeControl(question.key));
示例4:
this.contentForm.value.selectedParagraphs.forEach(para => {
this.contentForm.removeControl('text_' + para.paragraphNo);
});
示例5: removeItem
removeItem(productId: string) {
const index = this.products.findIndex(p => p.id === productId);
this.products.splice(index, 1);
this.cart.removeItem(productId);
this.formModel.removeControl(productId);
}