From a7479f657ab3f075d189c20e62c9b026cc1c1aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mis=CC=8Cko=20Hevery?= Date: Wed, 1 Feb 2017 15:41:14 -0800 Subject: [PATCH] fix: ngModel should use rxjs/symbol/observable to detect observable (#14236) PR closes #14236 --- modules/@angular/forms/src/model.ts | 5 +++-- modules/@angular/forms/src/private_import_core.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/@angular/forms/src/model.ts b/modules/@angular/forms/src/model.ts index d88f949c34..685584dced 100644 --- a/modules/@angular/forms/src/model.ts +++ b/modules/@angular/forms/src/model.ts @@ -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?`); } diff --git a/modules/@angular/forms/src/private_import_core.ts b/modules/@angular/forms/src/private_import_core.ts index 0292fbf02f..8de9d5f09f 100644 --- a/modules/@angular/forms/src/private_import_core.ts +++ b/modules/@angular/forms/src/private_import_core.ts @@ -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;