I'm trying to make a simple HTTP request using Angular, but I keep getting this error:
Property 'http' does not exist on type 'WorksService'.
import {Injectable} from 'angular2/core';
import {Http, HTTP_PROVIDERS, Response} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
export class Work {
constructor(public id: number, public name: string) { }
}
@Injectable()
export class WorksService {
constructor (private http: Http) {}
private _WorksUrl = 'api/projects'; // URL to web api
getHeroes () {
return this.http.get(this._WorksUrl)
.map(res => <Work[]> res.json().data)
.catch(this.handleError);
}
private handleError (error: Response) {
// instead of just logging it to the console
console.error(error);
return Observable.throw(error.json().error || 'Server error');
}
}
WorksService? Where does the object come from?