i found this great post Creating and returning Observable from Angular 2 Service and now I try to do the same, but get the this error:
core.umd.js:2838 EXCEPTION: Cannot read property 'next' of undefined
here is my service:
@Injectable()
export class ReadBuchungenService {
public activeProject : ReplaySubject<any>;
private get_all_buchungen_url : string = "xxxxxxx/xxx/";
constructor (private http : Http) {}
public load(timestamp : number) {
let params = new URLSearchParams();
params.set('timestamp', String(timestamp));
this.http.get(this.get_all_buchungen_url, { search: params })
.subscribe(res => this.activeProject.next(res));
return this.activeProject;
}
}
compiling in es6 and here are the dependencies from the package.json:
"dependencies": {
"@angular/common": "^2.2.4",
"@angular/compiler": "^2.1.2",
"@angular/core": "^2.2.4",
"@angular/http": "^2.1.4",
"@angular/platform-browser": "^2.1.2",
"@angular/platform-browser-dynamic": "^2.1.2",
"@angular/router": "^3.1.4",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "^0.19.40",
"zone.js": "^0.6.26"
}
Thanks!
ok now i tried to set the ReplaySubject Object width:
public activeProject : ReplaySubject<any> = new ReplaySubject(1);
but then i get a Unexpected token < error, also after a fresh installation of angular.
Image of the complete error: