2017-07-04 5 views
1

Ich folge dem phoneCat Tutorial [https://docs.angularjs.org/tutorial/] und entscheide mich, eine ähnlich strukturierte App zu erstellen. aber ich bekomme immer $ injector: modulerr Fehler, wenn ich versuche, ein Modul, das ich erstellt habe, zu integrieren.

Die Art, wie ich meine App gestartet habe, ist npm Paket http-Server mit Befehl http-Server ... \ app.

Eine andere Sache, die ich bemerkte, ist, dass, wenn ich http-Server-Befehl direkt (statt npm Start im Tutorial vorgeschlagen) zu starten App im App-Ordner gibt es auch mir eine Fehlermeldung. Ich bin jetzt ziemlich verwirrt darüber.

Das ist mein app.module.js ist

'use strict'; 

angular.module('dota2Hero', [ 
    'ngRoute', 
    'core' 
]); 

Wenn ich 'Kern' von Abhängigkeits Array entfernen, stellt der Code.

Hier ist meine index.html

<!doctype html> 
<html lang="en" ng-app="dota2Hero"> 

<head> 
    <meta charset="utf-8"> 
    <title>Dota2 Database</title> 

    <script src="//code.angularjs.org/1.6.1/angular.min.js"></script> 
    <script src="//code.angularjs.org/1.6.1/angular-route.min.js"></script> 
    <script src="core/hero/hero.module.js"></script> 
    <script src="core/core.module.js"></script> 
    <script src="app.module.js"></script> 
    <script src="core/hero/hero.service.js"></script> 
    <script src="app.config.js"></script> 
</head> 

<body> 

    <div ng-view></div> 

</body> 

</html> 

und meine core.module.js

'use strict'; 


angular.module('core',['core.hero']); 

Antwort

0

Sie müssen die Reihenfolge ändern, in dem Sie die Verweise laden, die core.module laden. js vor dem Laden app.module.js

<script src="https://code.angularjs.org/1.6.1/angular.min.js"></script> 
    <script src="https://code.angularjs.org/1.6.1/angular-route.min.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-resource/1.6.1/angular-resource.min.js"></script> 
    <script src="core/hero/hero.module.js"></script> 
    <script src="hero-grid/hero-grid.module.js"></script> 
    <script src="core/core.module.js"></script> 
    <script src="app.module.js"></script> 
    <script src="app.config.js"></script> 
    <script src="core/hero/hero.service.js"></script> 
    <script src="hero-grid/hero-grid.component.js"></script> 
+0

Danke für die Antwort, änderte ich meinen Code aber gleichen Fehler immer noch. –

+0

was ist der Fehler jetzt – Sajeetharan

+0

[Imgur] (http://i.imgur.com/ngV7jjp.png) –

Verwandte Themen