當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。