我尝试理解为什么编译器抛出"所提供的参数不匹配呼叫目标的任何签名"该代码中的任何签名"此代码中的错误",在ES6中编译的Angular 2.0中。
错误在线this.observer_data = this.http.get(this.get_all_buchungen_url ...
该服务提供了一个可观察的对象的" buchungspos"类型女巫,将使用load_and_init_buchungen()
函数初始化。
服务:
@Injectable()
export class ReadBuchungenService {
public observer_data : Observable<BuchungPos>;
constructor (private http : Http ) {}
public load_and_init_buchungen(timestamp : number) {
let params = new URLSearchParams();
params.set('timestamp', String(timestamp));
this.observer_data =
this.http.get(this.get_all_buchungen_url, { search: params })
.map(response => response.json());
return;
}
...
导入的buchngspos类看起来像:
export class BuchungPos {
constructor(public id : number,
public date : string,
public name : boolean
) {}
}
在app.component
中constructor(public readDataservice : ReadBuchungenService) {}
ngOnInit() {
this.readDataservice.load_and_init_buchungen(this.startTime);
}
并在其他组件中使用对象:
export class TagComponent implements OnInit {
private buchungPos : BuchungPos;
constructor( private readBuchungenService : ReadBuchungenService) { }
ngOnInit() {
this.readBuchungenService.observer_data.subscribe(
function (data) {
this.buchungPos = data.data;
}.bind(this)
);
}
}
我已经搜索了这个问题并找到了一些答案,但他们没有帮助我理解它。
angular2:所提供的参数不匹配呼叫目标的任何签名,即使我有所有必要的参数
Chart.js-提供的参数与呼叫目标的任何签名(Angular2)
我发现自己的错误,我必须使用最新的rxjs版本,这里是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"
}