Reputation: 2658
I have created an observable using Observable.of()
by importing it from rxjs/Observable
. But, editor was showing error. But, after so many trials I changed it from rxjs/Observable
to rxjs
. Then it worked fine. May I know the difference between those. I have referred some solutions for the similar questions. But, they did not provide the complete solution. Please help me understand this.
Thanks..
Upvotes: 0
Views: 5731
Reputation: 17374
When you import 'rxjs' you're importing the entire library. Because the library is large, this is not ideal. However, if you import Observable separately, you'll need to also include an import for 'of' separately, such as:
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
EDIT For Angular 6:
import { Observable } from 'rxjs';
import { of } from 'rxjs';
Upvotes: 7