【发布时间】:2017-04-21 07:02:15
【问题描述】:
我发现了这篇很棒的帖子Creating and returning Observable from Angular 2 Service,现在我尝试做同样的事情,但得到了这个错误:
core.umd.js:2838 异常:无法读取未定义的属性“下一个”
这是我的服务:
@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;
}
}
在 es6 中编译,这里是 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"
}
谢谢!
好的,现在我尝试设置 ReplaySubject 对象的宽度:
public activeProject : ReplaySubject<any> = new ReplaySubject(1);
但是我得到一个 Unexpected token
完整错误的图片:
【问题讨论】:
标签: javascript angular observable