本文整理匯總了TypeScript中@angular/forms.Validators.composeAsync方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Validators.composeAsync方法的具體用法?TypeScript Validators.composeAsync怎麽用?TypeScript Validators.composeAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/forms.Validators
的用法示例。
在下文中一共展示了Validators.composeAsync方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should ignore nulls', () => {
const v = Validators.composeAsync([observableValidator({'one': true}), null !]) !;
let errorMap: {[key: string]: any} = undefined !;
first.call(v(new FormControl('invalid')))
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
expect(errorMap).toEqual({'one': true});
});
示例2: FormControl
dynamicFormModel.items.forEach(controlModel => {
formGroup[controlModel.id] = new FormControl(
controlModel.value || null,
Validators.compose(controlModel.validators),
Validators.composeAsync(controlModel.validatorsAsync)
);
});
示例3: it
it('should ignore nulls', fakeAsync(() => {
const v = Validators.composeAsync([promiseValidator({'one': true}), null]);
let errorMap: {[key: string]: any};
first.call(v(new FormControl('invalid')))
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
tick();
expect(errorMap).toEqual({'one': true});
}));
示例4: it
it('should collect errors from all the validators', () => {
const v = Validators.composeAsync(
[observableValidator({'one': true}), observableValidator({'two': true})]) !;
let errorMap: {[key: string]: any} = undefined !;
(v(new FormControl('invalid')) as Observable<ValidationErrors|null>)
.pipe(first())
.subscribe((errors: {[key: string]: any}) => errorMap = errors);
expect(errorMap).toEqual({'one': true, 'two': true});
});