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


TypeScript AbstractControl.setValue方法代码示例

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


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

示例1: handleTimeClearedEvent

 handleTimeClearedEvent() {
     if (this.control) {
         this.model.resetMessage();
         this.model.clientValid = true;
         this.control.setValue('');
     }
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:7,代码来源:time-picker-facade.component.ts

示例2: setValue

 /**
  * Changes the value of a control
  */
 setValue(control: AbstractControl | string, value: any, markAsDirty?: boolean): AbstractControl {
   control = this.getControl(control);
   if (markAsDirty) {
     control.markAsDirty();
   }
   control.setValue(value);
   return control;
 }
开发者ID:YankunLi,项目名称:ceph,代码行数:11,代码来源:unit-test-helper.ts

示例3: handleInvalidTimeEvent

 handleInvalidTimeEvent(data: string) {
     if (this.control) {
         this.control.setValue('');
         this.model.setInvalidTime();
         this.model.clientValid = false;
         this.control.setErrors({ [this.model.getMessage()]: true });
     }
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:8,代码来源:time-picker-facade.component.ts

示例4: it

  it('Inland Location Is Set: Form Should be Valid', () => {


    inland.setValue('DEDUS');
    fixture.detectChanges();
    expect(component.form.valid).toBeTruthy();
    expect(component.isInvalid()).toBeFalsy();
  });
开发者ID:Eckhardo,项目名称:Aige_Angular,代码行数:8,代码来源:search-intermodal.component.spec.ts

示例5: setValueIfChanged

    setValueIfChanged(time: string) {
        const oldValue = this.control.value;
        const newValue = time ? time : '';

        if (newValue !== oldValue) {
            this.model.resetMessage();
            this.model.clientValid = true;
            this.control.setValue(newValue);
        }
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:10,代码来源:time-picker-facade.component.ts

示例6: it

        it('should have invalid CartesianPosition fields when 1 or 2 is changed in group', () => {
            let x: AbstractControl = comp.cartesianPositionForm.controls['x'];
            let y: AbstractControl = comp.cartesianPositionForm.controls['y'];
            let z: AbstractControl = comp.cartesianPositionForm.controls['z'];
            let xInvalid: HTMLInputElement = dom.querySelector('number-input[controlname="x"] small') as HTMLInputElement;
            let yInvalid: HTMLInputElement = dom.querySelector('number-input[controlname="y"] small') as HTMLInputElement;
            let zInvalid: HTMLInputElement = dom.querySelector('number-input[controlname="z"] small') as HTMLInputElement;

            // Setting one or two of x,y,z should cause all to become required and others to be invalid
            x.setValue(7);
            fixture.detectChanges();
            expect(x.valid).toBeTruthy();
            expect(y.valid).toBeFalsy();
            expect(z.valid).toBeFalsy();
            expect(xInvalid.textContent).toEqual('');
            expect(yInvalid.textContent).toContain('Field required');
            expect(zInvalid.textContent).toContain('Field required');

            y.setValue(77);
            fixture.detectChanges();
            expect(x.valid).toBeTruthy();
            expect(y.valid).toBeTruthy();
            expect(z.valid).toBeFalsy();
            expect(xInvalid.textContent).toEqual('');
            expect(yInvalid.textContent).toEqual('');
            expect(zInvalid.textContent).toContain('Field required');

            // Set them all and they should now be valid
            z.setValue(777);
            fixture.detectChanges();
            expect(x.valid).toBeTruthy();
            expect(y.valid).toBeTruthy();
            expect(z.valid).toBeTruthy();
            expect(xInvalid.textContent).toEqual('');
            expect(yInvalid.textContent).toEqual('');
            expect(zInvalid.textContent).toEqual('');

            // take away all the values and they should be valid also
            x.setValue(null);
            y.setValue(null);
            z.setValue(null);
            fixture.detectChanges();
            expect(x.valid).toBeTruthy();
            expect(y.valid).toBeTruthy();
            expect(z.valid).toBeTruthy();
            expect(xInvalid.textContent).toEqual('');
            expect(yInvalid.textContent).toEqual('');
            expect(zInvalid.textContent).toEqual('');
        });
开发者ID:GeoscienceAustralia,项目名称:gnss-site-manager,代码行数:49,代码来源:site-location.component.spec.ts

示例7: fakeAsync

 fakeAsync(() => {
   x.setValue('xyz');
   tick(500);
   expect(x.hasError('notUnique')).toBeTruthy();
   expect(x.valid).toBeFalsy();
 })
开发者ID:yanghonggang,项目名称:ceph,代码行数:6,代码来源:cd-validators.spec.ts

示例8: it

 it('should not error because of empty input', () => {
   x.setValue('');
   expect(x.hasError('notUnique')).toBeFalsy();
   expect(x.valid).toBeTruthy();
 });
开发者ID:yanghonggang,项目名称:ceph,代码行数:5,代码来源:cd-validators.spec.ts

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