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


TypeScript AbstractControl.markAsTouched方法代碼示例

本文整理匯總了TypeScript中@angular/forms.AbstractControl.markAsTouched方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AbstractControl.markAsTouched方法的具體用法?TypeScript AbstractControl.markAsTouched怎麽用?TypeScript AbstractControl.markAsTouched使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/forms.AbstractControl的用法示例。


在下文中一共展示了AbstractControl.markAsTouched方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: buildForm

 private buildForm(): void {
     this.form = this.formBuilder.group({
         firstName: [this.firstName, Validators.required],
         lastName: [this.lastName, Validators.required],
         email: [this.email, Validators.compose([Validators.required, CustomValidators.email])]
     });
     this.firstNameControl = this.form.controls.firstName;
     this.lastNameControl = this.form.controls.lastName;
     this.emailControl = this.form.controls.email;
     if (this.item) {
         this.firstNameControl.markAsTouched();
         this.lastNameControl.markAsTouched();
         this.emailControl.markAsTouched();
     }
 }
開發者ID:taylorjg,項目名稱:Angular2Dialog,代碼行數:15,代碼來源:nameListItemModalContent.component.ts

示例2: showErrors

export function showErrors(control: AbstractControl) {
    if ((control as FormGroup | FormArray).controls) {
        // tslint:disable-next-line:forin
        for (const name in (control as FormGroup | FormArray).controls) {
            showErrors((control as FormGroup).controls[name]);
        }
    }
    control.markAsTouched({ onlySelf: true });
    control.updateValueAndValidity({ onlySelf: true });
}
開發者ID:mikule1,項目名稱:epool.eu,代碼行數:10,代碼來源:showErrors.ts

示例3: markAsDeeplyTouched

export function markAsDeeplyTouched(control: AbstractControl): void {
  // Mark this control as touched
  control.markAsTouched();

  // Recursively mark any control children as touched
  if (control instanceof FormGroup) {
    Object.keys(control.controls).forEach(key => {
      const c2 = control.get(key);
      if (c2) {
        markAsDeeplyTouched(c2);
      }
    });
  }
}
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:14,代碼來源:utils.ts

示例4: dirty

 /*
  Ensures a programmatic change to an AbstractControl value is marked as dirty (and by default as touched)
  prior to the change, properly invoking validation and the display of any validation errors.
 */
 changeControlValue( control: AbstractControl, value: any, markTouched: boolean = true ) : void {
     control.markAsDirty();
     control.markAsTouched( markTouched );
     control.setValue( value );
 }
開發者ID:bcswartz,項目名稱:angular2-sandbox-guildrunner,代碼行數:9,代碼來源:vadacl.ts


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