fix: ngModel should use rxjs/symbol/observable to detect observable (#14236)
PR closes #14236
This commit is contained in:
parent
bc20e8ac9d
commit
a7479f657a
@ -11,7 +11,8 @@ import {fromPromise} from 'rxjs/observable/fromPromise';
|
|||||||
import {composeAsyncValidators, composeValidators} from './directives/shared';
|
import {composeAsyncValidators, composeValidators} from './directives/shared';
|
||||||
import {AsyncValidatorFn, ValidatorFn} from './directives/validators';
|
import {AsyncValidatorFn, ValidatorFn} from './directives/validators';
|
||||||
import {EventEmitter, Observable} from './facade/async';
|
import {EventEmitter, Observable} from './facade/async';
|
||||||
import {isPromise} from './private_import_core';
|
import {isObservable, isPromise} from './private_import_core';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -419,7 +420,7 @@ export abstract class AbstractControl {
|
|||||||
if (this.asyncValidator) {
|
if (this.asyncValidator) {
|
||||||
this._status = PENDING;
|
this._status = PENDING;
|
||||||
const obs = toObservable(this.asyncValidator(this));
|
const obs = toObservable(this.asyncValidator(this));
|
||||||
if (!(obs instanceof Observable)) {
|
if (!(isObservable(obs))) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`expected the following validator to return Promise or Observable: ${this.asyncValidator}. If you are using FormBuilder; did you forget to brace your validators in an array?`);
|
`expected the following validator to return Promise or Observable: ${this.asyncValidator}. If you are using FormBuilder; did you forget to brace your validators in an array?`);
|
||||||
}
|
}
|
||||||
|
@ -9,3 +9,4 @@
|
|||||||
import {__core_private__ as r} from '@angular/core';
|
import {__core_private__ as r} from '@angular/core';
|
||||||
|
|
||||||
export const isPromise: typeof r.isPromise = r.isPromise;
|
export const isPromise: typeof r.isPromise = r.isPromise;
|
||||||
|
export const isObservable: typeof r.isObservable = r.isObservable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user