如果我在浏览器控制台中执行此操作,则似乎不会调用构造函数-
Observable.create(observer =>
console.log('this is the observer'); //doesn't gets logged
this.alertObserver = observer
);
或这个 :-
new Observable(observer =>
console.log('this is the observer'); //doesn't gets logged
this.alertObserver = observer
);
我尝试通过导入观察者
import {Observable} from 'rxjs/Observable';
和
import {Observable} from 'rxjs/Rx';
但没有帮助。
有什么建议吗?