'Error' message: 'Property 'from' does not exist on type 'typeof Observable'

人走茶凉 提交于 2019-12-04 03:44:59

Change

import { Observable} from 'rxjs/Observable'
import 'rxjs/observable/from'

To

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/from';

If you are using rxjs >=6.0.0 then you no longer use Observable.from. Instead from is a standalone function.

import { Observable, from} from 'rxjs';

//old way
var o = Observable.from([1, 2, 3, 4]);

//new way
var o = from([1, 2, 3, 4]);

I hope this is helpful since it took me a while to figure this out.

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