Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an Observable for Mock Data in Angular 2

I am trying to return an Observable from a service with mock data.

I am returning this from my service :

return Observable.of(new Object()).map(MOCKACCOUNT =>JSON.stringify(MOCKACCOUNT)); 

I get an error

Observable_1.Observable.of is not a function.

Am I missing some include? I am importing

import {Observable} from "rxjs/Observable"; 

Note: I was returning a mock promise prior but based on my understanding I would not be able to interpolate the value. For example {{returnFromServiceStoredInExportedClass.name}}

like image 858
Chris Avatar asked Feb 15 '16 16:02

Chris


1 Answers

Looks like

import {Observable} from "rxjs/Observable"; 

should be

import {Observable} from "rxjs/Rx"; 

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

like image 58
Günter Zöchbauer Avatar answered Oct 10 '22 23:10

Günter Zöchbauer