I’m back with another problem.. I have an API on my local server, and I want to communicate with it. But when I do
import {Http, Response} from 'angular2/http'; or
import { HTTP_PROVIDERS } from 'angular2/http'; or
import {HTTP_BINDINGS} from 'angular2/http'; or
import {Http, Response} from 'angular2/http';
I got an error? “404 GET /angular2/http” in the console.
Here is my toolservice.ts :
import {Injectable} from 'angular2/core';
import {Http, Response} from 'angular2/http';
import {Tool} from './tool';
import {BackendService} from './backend.service';
@Injectable()
export class ToolService {
constructor(
private _backend: BackendService /*,http: Http*/ ){ }
private _tools:Tool[] = [];
getTools() {
this._backend.getAll(Tool).then( (tools:Tool[]) => {
this._tools.push(...tools); // fill cache
});
return this._tools; }
/*launchtool(){
alert("I asked to launch your tool...");
http.get("http://localhost:8080/");
//this.http.get("http://localhost:8080/");
//$http.get("http://localhost:8080/");
}*/
}
If I uncomment “private _backend: BackendService /, private http: Http/ ){ }“ I got an error cause angular can’t find http.
Did I miss something? I try to do npm install –g http and http-request but it was uneffective..