本文整理匯總了TypeScript中@angular/forms.FormControl.disable方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript FormControl.disable方法的具體用法?TypeScript FormControl.disable怎麽用?TypeScript FormControl.disable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/forms.FormControl
的用法示例。
在下文中一共展示了FormControl.disable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should mark the control as disabled', () => {
const c = new FormControl(null);
expect(c.disabled).toBe(false);
expect(c.valid).toBe(true);
c.disable();
expect(c.disabled).toBe(true);
expect(c.valid).toBe(false);
c.enable();
expect(c.disabled).toBe(false);
expect(c.valid).toBe(true);
});
示例2: it
it('should not run validators on disabled controls', () => {
const validator = jasmine.createSpy('validator');
const c = new FormControl('', validator);
expect(validator.calls.count()).toEqual(1);
c.disable();
expect(validator.calls.count()).toEqual(1);
c.setValue('value');
expect(validator.calls.count()).toEqual(1);
c.enable();
expect(validator.calls.count()).toEqual(2);
});
示例3: it
it('should ignore disabled array controls when determining dirtiness', () => {
const c = new FormControl('one');
const c2 = new FormControl('two');
const a = new FormArray([c, c2]);
c.markAsDirty();
expect(a.dirty).toBe(true);
c.disable();
expect(c.dirty).toBe(true);
expect(a.dirty).toBe(false);
c.enable();
expect(a.dirty).toBe(true);
});
示例4: it
it('should throw if a value is not provided for a disabled control', () => {
c2.disable();
expect(() => a.setValue(['one']))
.toThrowError(new RegExp(`Must supply a value for form control at index: 1`));
});