当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript FormGroup.patchValue方法代码示例

本文整理汇总了TypeScript中@angular/forms.FormGroup.patchValue方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FormGroup.patchValue方法的具体用法?TypeScript FormGroup.patchValue怎么用?TypeScript FormGroup.patchValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/forms.FormGroup的用法示例。


在下文中一共展示了FormGroup.patchValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: ngOnInit

 ngOnInit() {
   this.settingsForm = this.fb.group({
     id: 1,
     server_url: ['', Validators.required ]
   });
   this.settingsForm.patchValue({ server_url: localStorage.getItem('server_url') });
 }
开发者ID:Rachoor,项目名称:pia,代码行数:7,代码来源:settings.component.ts

示例3:

 			user => {
 				this.id = user.id;
 				this.userForm.patchValue({
 					username: user.username,
 					address: user.address,
 					email: user.email
 				});
 			}, error => {
开发者ID:Silhris,项目名称:Test,代码行数:8,代码来源:user-detail.component.ts

示例4: onEditButton

 /**
  * Category specific edit button
  * @param viewCategory individual cat
  */
 public onEditButton(viewCategory: ViewCategory): void {
     this.editId = viewCategory.id;
     this.updateForm.reset();
     this.updateForm.patchValue({
         prefix: viewCategory.category.prefix,
         name: viewCategory.name
     });
 }
开发者ID:emanuelschuetze,项目名称:OpenSlides,代码行数:12,代码来源:category-list.component.ts

示例5:

			this.profileService.getProfile(user.username).subscribe((profile :Profile)=>{
				this.profile_form.patchValue({
					'name' : profile['name'],
					'bio' : profile['bio'],
					'company' : profile['company']
				});
				this.profile_image = profile.profile_image;
			});
开发者ID:SpacePorts,项目名称:CubesatDatabase,代码行数:8,代码来源:account-profile.component.ts

示例6: clearInputImage

 clearInputImage(field: string, fieldContentType: string, idInput: string) {
   this.editForm.patchValue({
     [field]: null,
     [fieldContentType]: null
   });
   if (this.elementRef && idInput && this.elementRef.nativeElement.querySelector('#' + idInput)) {
     this.elementRef.nativeElement.querySelector('#' + idInput).value = null;
   }
 }
开发者ID:jbbfreitas,项目名称:BestMeal,代码行数:9,代码来源:restaurante-update.component.ts

示例7: updateIngredients

 private updateIngredients(newIngredient: Ingredient): void {
     const ingredients = this.getCurrentIngredients();
     const existingIndex = findIndex(ingredients, ((i) => i.id === newIngredient.id));
     if (existingIndex > -1) {
         ingredients[existingIndex] = newIngredient;
     } else {
         ingredients.push(newIngredient);
     }
     this.recipeForm.patchValue({ingredients});
 }
开发者ID:tvsloot,项目名称:recipe-block,代码行数:10,代码来源:create-recipe.component.ts

示例8: ngOnChanges

 ngOnChanges(changes: SimpleChanges) {
   if(changes.candidate) {
     this.form.patchValue({
       'panelId': this.panelId,
       'boardId': this.boardId,
       'candidateId': this.candidate.id,
       'recordId': this.candidate.recordId,
     })
   }
 }
开发者ID:wolfhoundjesse,项目名称:AMI,代码行数:10,代码来源:candidate-file-upload.component.ts

示例9: ngOnInit

 ngOnInit() {
     this.form = this.fb.group({
         pay_account: [null, Validators.compose([Validators.required, Validators.email])],
         receiver_type: [null, [Validators.required]],
         receiver_account: [null, [Validators.required]],
         receiver_name: [null, Validators.compose([Validators.required, Validators.minLength(2)])],
         amount: [null, Validators.compose([Validators.required, Validators.pattern(`[0-9]+`), Validators.min(1), Validators.max(10000 * 100)])]
     });
     this.form.patchValue(this.item);
 }
开发者ID:duxie,项目名称:ng-alain,代码行数:10,代码来源:step1.component.ts

示例10: displayData

 displayData(): void {
     //this.postForm.setValue({
     //    title: '샘플 제목',
     //    content: '샘플 내용\n샘플 내용\n',
     //    blogId: 1
     //});
     this.postForm.patchValue({
         title: '샘플 제목',
         content: '샘플 내용\n샘플 내용\n'
     });
 }
开发者ID:VisualAcademy,项目名称:DotNetNote,代码行数:11,代码来源:PostModify.ts

示例11: autoFill

 @DeveloperFunction({
   args: [
     {
       username: 'NextFaze',
       password: 'devmod-development'
     }
   ]
 })
 autoFill(args: any) {
   this.form.patchValue(args);
 }
开发者ID:cybernetics,项目名称:devmod,代码行数:11,代码来源:login.component.ts

示例12: loadApiData

 loadApiData(){
   this.registrationForm.patchValue({
     userName: "Jonathan",
     password: "test",
     confirmPassword: "test",
     address: {
       city: "Miami",
       state: "FL",
       postalCode: "33023"
     }
   });
 }
开发者ID:jon-campbell1,项目名称:Angular-Reactive-Forms,代码行数:12,代码来源:app.component.ts

示例13: 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]
     });
 }
开发者ID:CatoTH,项目名称:OpenSlides,代码行数:18,代码来源:amendment-create-wizard.component.ts

示例14: ngOnInit

  ngOnInit() {
    this.createForm();
    this.store.select(fromStore.getBoard).subscribe(boardDetails => this.board = boardDetails);

    this.form.patchValue({
      active: this.board.active,
      title: this.board.title,
      rankId: this.board.rank.id,
      conveneOn: this.board.conveneOn,
    });
    this.setObjectives();
  }
开发者ID:ArmyMusicOnline,项目名称:ami,代码行数:12,代码来源:edit-board.component.ts

示例15:

					.subscribe((response) => {

						this.errormsg = '';
						this.coreservice.emitSuccessMessage(response.message);
						//this.successmsg = response.data.message;
						window.localStorage['teem_user'] = JSON.stringify(response.data);

						this.accountFormGroup.patchValue({
							email: response.data.email
						});
						this.router.navigate(['']);

					},
开发者ID:NachoJ,项目名称:teem,代码行数:13,代码来源:account.component.ts


注:本文中的@angular/forms.FormGroup.patchValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。