Why am I getting a error loading rxjs-extensions in Angular 2?

六眼飞鱼酱① 提交于 2019-11-29 14:03:25

Add rxjs-extensions.ts file in your app folder. Content of this file looks like below-

// Observable class extensions
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
// Observable operators
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';

and in your app/app.component.ts, import like this-

import './rxjs-extensions';

See if this helps.

I have had the same issue. Looking at John Papas completed code here-

https://github.com/johnpapa/angular2-tour-of-heroes/blob/master/app/hero-detail.component.ts

He doesn't import it at all. I have just tried commenting it out and it still seems to be working.

Having just completed the routes section, and this is the case. You don't need to import the rxjs as far as i can see.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!