I'm pretty new to Angular and have been stuck for some time now. I am trying to make a service that gets data from an internal webapi, it worked before but now it gives an error that i'm unable to solve. Hope one of you guys can help me... The service:
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);
}
}
The error it gives while compiling to 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.
Your decorator should look like:
@Injectable()
Parentheses are required
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With