fix: ngModel should use rxjs/symbol/observable to detect observable (#14236)

PR closes #14236
This commit is contained in:
Miško Hevery 2017-02-01 15:41:14 -08:00 committed by Miško Hevery
parent bc20e8ac9d
commit a7479f657a
2 changed files with 4 additions and 2 deletions

View File

@ -11,7 +11,8 @@ import {fromPromise} from 'rxjs/observable/fromPromise';
import {composeAsyncValidators, composeValidators} from './directives/shared';
import {AsyncValidatorFn, ValidatorFn} from './directives/validators';
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) {
this._status = PENDING;
const obs = toObservable(this.asyncValidator(this));
if (!(obs instanceof Observable)) {
if (!(isObservable(obs))) {
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?`);
}

View File

@ -9,3 +9,4 @@
import {__core_private__ as r} from '@angular/core';
export const isPromise: typeof r.isPromise = r.isPromise;
export const isObservable: typeof r.isObservable = r.isObservable;