I\'ve been playing with Angular 2 Quickstart.
How can I use/import http module in Angular 2?
I\'ve looked at Angular 2 Todo\'s.js, but it doesn\'t use the ht
import {Injectable} from 'angular2/core';
import {Http, HTTP_PROVIDERS} from 'angular2/http';
@Injectable()
export class GroupSelfService {
items:Array;
constructor(http:Http){
http.get('http://127.0.0.1:8080/src/data/names.json')
.subscribe(res => {
this.items = res;
console.log('results found');
})
}
}
Results in a 404:
File change detected
File change detected
GET /src/angular2/http 404 0.124 ms - 30
Two strange things:
1. /src/angular2/http - is not the path where http can be found and not the path I've provided in the code.
2. core.js lies just beside http.js in the node_modules/angular2 folder and is found.
How strange is that?
Update
Mea culpa: None of the examples mentioned that you need to reference the http.js in your html like
...and then it worked.
But for the path in the error message I still have no explanation.