2016-07-11 7 views
0

Ich bin angle.io Tutorial folgen, um angular2 zu lernen. Ich habe seine Schritte verfolgt.Angular2 Server verbinden

erstellt

package.json 
systemjs.config.js 
tsconfig.ts 
typings.json 

Dateien

schafft app.components.ts

import { component } from '@angular/core' 
@Component({ 
    selector:'my-app', 
    template:'<h1>My First Angular 2 App</h1>' 
}); 

export class AppComponent{} 

main.ts

import { bootstrap } from '@angular/platform-browser-dynamic'; 
import { Appcomponent } from './app.components'; 

bootstrap(Appcomponent); 

und schließlich index.html

<html> 
    <head> 
    <title>Angular 2 QuickStart</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="styles.css"> 
    <!-- 1. Load libraries --> 
    <!-- Polyfill(s) for older browsers --> 
    <script src="node_modules/core-js/client/shim.min.js"></script> 
    <script src="node_modules/zone.js/dist/zone.js"></script> 
    <script src="node_modules/reflect-metadata/Reflect.js"></script> 
    <script src="node_modules/systemjs/dist/system.src.js"></script> 
    <!-- 2. Configure SystemJS --> 
    <script src="systemjs.config.js"></script> 
    <script> 
     System.import('app').catch(function(err){ console.error(err); }); 
    </script> 
    </head> 
    <!-- 3. Display the application --> 
    <body> 
    <my-app>Loading...</my-app> 
    </body> 
</html> 

noch während npm start mit ihm die Konsole starten wirft nur Fehler

Failed to load resource: the server responded with a status of 404 (Not Found) 
http://localhost:3000/app/main.js Failed to load resource: the server responded with a status of 404 (Not Found) 
localhost/:16 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/app/main.js(…)(anonymous function) @ localhost/:16 
3content.js:191 NO OEMBED 
http://localhost:3000/styles.css Failed to load resource: the server responded with a status of 404 (Not Found) 

gibt es einen eingebauten Server? Tutorial zeigt keine Servereinstellungen an. Warum passiert das und wie kann ich es reparieren?

dank

+0

Nur um sicher zu sein: Sie haben alle Knotenmodule mit 'npm install' installiert, bevor Sie' npm start' ausgeführt haben, richtig? –

+0

@ErikvandeVen ja ich habe – user3706129

+0

Erstellt die styles.css auch? Weil es auch eine 404 für diese Datei zurückgibt. –

Antwort

0

ändern Ordnername "app.components.ts" auf "app.component.ts" und innen main.ts change "Appcomponent" auf "AppComponent". es sollte geschrieben werden CamelCase

+0

das gleiche Ergebnis wie vorher – user3706129

+0

auch dies ändern. "von" ./app.components '"bis" von' ./app.component '" – Sajad