當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript FormGroup.removeControl方法代碼示例

本文整理匯總了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);
        }
    }
開發者ID:thanhdevapp,項目名稱:ng-dynamic-forms,代碼行數:13,代碼來源:dynamic-form.service.ts

示例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
            });
        }
    }
開發者ID:CatoTH,項目名稱:OpenSlides,代碼行數:39,代碼來源:amendment-create-wizard.component.ts

示例3:

 .forEach(question => form.removeControl(question.key));
開發者ID:yeg-relief,項目名稱:screenerClient,代碼行數:1,代碼來源:question-control.service.ts

示例4:

 this.contentForm.value.selectedParagraphs.forEach(para => {
     this.contentForm.removeControl('text_' + para.paragraphNo);
 });
開發者ID:CatoTH,項目名稱:OpenSlides,代碼行數:3,代碼來源:amendment-create-wizard.component.ts

示例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);
 }
開發者ID:JCarran0,項目名稱:ng-shop,代碼行數:6,代碼來源:cart.component.ts


注:本文中的@angular/forms.FormGroup.removeControl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。