I am having issue with importing Observable.of
function in my project. My Intellij sees everything. In my code I have:
import {Observable} from 'rxjs/Observable';
and in my code I use it like that:
return Observable.of(res);
Any ideas?
I am having issue with importing Observable.of
function in my project. My Intellij sees everything. In my code I have:
import {Observable} from 'rxjs/Observable';
and in my code I use it like that:
return Observable.of(res);
Any ideas?
Upgraded from Angular 5 / Rxjs 5 to Angular 6 / Rxjs 6?
You must change your imports and your instantiation. Check out Damien's blog post
Tl;dr:
shows a requirement of rxjs-compat
I did not have this installed. Installed by
and rerunning fixed my issue.
For me (Angular 5 & RxJS 5) the autocomplete import suggested:
import { Observable } from '../../../../../node_modules/rxjs/Observable';
while to should be (with all static operators
from
,of
, e.c.t working fine:import { Observable } from 'rxjs/Observable';
RxJS 6
When upgrading to version 6 of the
RxJS
library and not using therxjs-compat
package the following codehas to be changed into
Actually I have imports messed up. In latest version of RxJS we can import it like that:
Although it sounds absolutely strange, with me it mattered to capitalize the 'O' in the import path of
import {Observable} from 'rxjs/Observable
. The error message withobservable_1.Observable.of is not a function
stays present if I import the Observable fromrxjs/observable
. Strange but I hope it helps others.