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


TypeScript FormControl.markAsTouched方法代碼示例

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


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

示例1: it

      it('should not set the parent untouched state if other touched controls', () => {
        const c2 = new FormControl('two');
        const g = new FormGroup({'one': c, 'two': c2});
        c.markAsTouched();
        c2.markAsTouched();

        c.reset();
        expect(g.untouched).toBe(false);
      });
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:9,代碼來源:form_control_spec.ts

示例2: it

      it('should mark all child controls as untouched', () => {
        c.markAsTouched();
        c2.markAsTouched();
        expect(c.untouched).toBe(false);
        expect(c2.untouched).toBe(false);

        a.reset();
        expect(c.untouched).toBe(true);
        expect(c2.untouched).toBe(true);
      });
開發者ID:manekinekko,項目名稱:angular,代碼行數:10,代碼來源:form_array_spec.ts

示例3: it

    it('should showError when field is touched and form is invalid', () => {
      const field = {},
        formControl = new FormControl(null, Validators.required),
        options = { parentForm: { submitted: false } };

      formControl.markAsTouched();

      expect(config.extras.showError({ options, formControl, field } as any)).toBeTruthy();
    });
開發者ID:formly-js,項目名稱:ng2-formly,代碼行數:9,代碼來源:formly.config.spec.ts

示例4: onSubmit

  onSubmit(params) {
    this.passwordConfirmation.updateValueAndValidity({});
    this.passwordConfirmation.markAsTouched();
    if (!this.myForm.valid) return;

    this.userService.updateMe(omitBy(params, isEmpty))
      .subscribe(() => {
        toastr.success('Successfully updated.');
      }, this.handleError);
  }
開發者ID:Angular-Reference,項目名稱:angular2-app,代碼行數:10,代碼來源:user-edit.component.ts

示例5: it

 it('resets a control', () => {
   let control: FormControl = new FormControl('');
   let returnedControl: AbstractControl = null;
   control.markAsTouched();
   control.updateValue('dave');
   returnedControl = Utils.resetControl(control);
   expect(returnedControl.touched).toBe(false);
   expect(returnedControl.untouched).toBe(true);
   expect(returnedControl.pristine).toBe(true);
   expect(returnedControl.dirty).toBe(false);
   expect(returnedControl.value).toBe('');
 });
開發者ID:CheckHealthCo,項目名稱:clicker,代碼行數:12,代碼來源:utils.spec.ts


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