本文整理汇总了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`));
});