4
我是Angular的新手,現在已經停留了一段時間。我試圖做一個服務,從內部webapi獲取數據,它以前工作,但現在它給出了我無法解決的錯誤。希望你們中的一個可以幫助我... 服務:Angular 2服務錯誤。找不到原因
import {Injectable} from "@angular/core";
import {Http} from '@angular/http';
import 'rxjs/add/operator/toPromise';
import {GraphData} from './graph-data';
@Injectable
export class GraphDataService {
private dataApiUrl = 'app/graph-data';
constructor(private http: Http) {}
getGraphData() : Promise<GraphData[]> {
return this.http.get(this.dataApiUrl)
.toPromise()
.then(response => response.json().data as GraphData[])
.catch(this.handleError);
}
private handleError(error: any): Promise<any> {
console.error('an error occurred', error); // only for demo
return Promise.reject(error.message || error);
}
}
在編譯到JS它給人的錯誤:
app/graph-data.service.ts(11,1): error TS1238: Unable to resolve signature of class decorator when called as an expression.
Supplied parameters do not match any signature of call target.
該死的,這解決了我的問題......謝謝!已經在它上面好幾個小時 –
我在Typescript上做了一個pull請求來解決這個問題,錯誤信息不清楚我經常看到這個錯誤。 – bokan