当前位置: 首页>>代码示例>>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;未经允许,请勿转载。