I tried to use the Angular2/http module within my Angular 2 app, but when I try to import it system.src.js throws an error http:///angular2/http 404 not Found.
Heres how my index.html looks like:
<html>
<head>
<title>Angular 2 QuickStart</title>
<!-- 1. Load libraries -->
<script src="angular2/bundles/angular2-polyfills.js"></script>
<script src="systemjs/dist/system.src.js"></script>
<script src="rxjs/bundles/Rx.js"></script>
<script src="angular2/bundles/angular2.dev.js"></script>
<!-- 2. Configure SystemJS -->
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
</script>
<link href="bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="assets/styles/main.css" rel="stylesheet">
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
boot.ts
import {bootstrap} from 'angular2/platform/browser'
import {AppComponent} from './app.component'
bootstrap(AppComponent);
The component where I try to import http:
import {Injectable} from 'angular2/core';
import {Track} from './track'
import {Http, Headers} from 'angular2/http';
@Injectable()
export class ActionTracker {
constructor(private _http : Http){}
login(){
this._http.post('/api/login', "")
.map(res => res.json())
.subscribe(
data => console.log(data),
err => console.log(err),
() => console.log('Authentication Complete')
);
}
}
Would be great if anyone could explain how to make the import work. I also tried to import a third party lib before where I failed too.
Thanks for your help.