本文整理匯總了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);
}