Angular2 RxJS getting 'Observable_1.Observable.fromEvent is not a function' error

后端 未结 2 1382
半阙折子戏
半阙折子戏 2020-12-24 04:49

I\'m using AngularJS 2 Beta 0 and I\'m trying to create an RxJS Observable from an event on a window object. I believe I know the formula for capturing the event as an Obse

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 05:34

    The problem seemed to be that the import statement should look like this:

    import {Observable} from 'rxjs/Rx';
    

    Note that Observable is being brought in from rxjs/Rx instead of from rxjs/Observable. As @EricMartinez mentions, pulling it in this way will automagically get you all of the operators (like .map()).

提交回复
热议问题