2016-04-09 1 views
1

Ich habe diese Hauptanwendung namens Dashboard und ich möchte ein maßgeschneidertes Modul namens Core injizieren.

Ich bekomme diese Injektion Fehler und ich habe keine Ahnung warum. Ich folge einer Vorlage, die mein Kollege hat, und es ist ziemlich Wort für Wort, also weiß ich nicht, warum es nicht für mich arbeitet.

app.js

(function(){ 

    'use strict'; 

    var dependencies = [ 
     'ngRoute', 
     'core' 

    ]; // all our modules 

    angular.module('dashboard', dependencies).config(Config); //.config(Config); 

    Config.$inject = ['$locationProvider']; 

    function Config($locationProvider){ 
     $locationProvider.hashPrefix('!'); 

    } 

    angular.element(document).ready(function(){ 

     angular.bootstrap(document, ['dashboard']); 


    }); 

})(); 

layout.hbs

<!DOCTYPE html> 
<html> 
    <head> 
    <title>{{title}}</title> 
    <link rel='stylesheet' href='/javascripts/bootstrap/dist/css/bootstrap.css' /> 
    <link rel='stylesheet' href='/stylesheets/style.css' /> 
    </head> 
    <body> 
    <div class="flud-container"> 
      {{{body}}} 
    </div> 
    </body> 

    <!-- JS Libraries --> 
    <script type='text/javascript' src='/lib/jquery/dist/jquery.min.js'></script> 
    <script type='text/javascript' src='/lib/bootstrap/dist/js/bootstrap.min.js'></script> 
    <script type='text/javascript' src='/lib/angular/angular.min.js'></script> 
    <script type='text/javascript' src='/lib/angular-route/angular-route.min.js'></script> 

    <script type='text/javascript' src='/modules/core/core.client.module.js'></script> 
    <script type='text/javascript' src='/modules/core/config/core.client.routes.js'></script> 
    <script type='text/javascript' src='/app.js'></script> 
</html> 

core.client.module.js

(function(){ 

    'use strict'; 

// var dependencies = [ 


// ]; 

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

    angular.module('core').run(intialize); 

    initialize.$inject = ['$rootScope', '$location']; 

    function intitialize($rootScope, $location){ 

     //initialize module's variables here 

    } 




}); 

Konsole Fehler:

angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.3/$injector/modulerr?p0=dashboard&p1=Error%…(http%3A%2F%2Flocalhost%3A3000%2Flib%2Fangular%2Fangular.min.js%3A20%3A463) 
+1

aus dem Stacktrace unklar ist es, die Modile ist es, die Fehler zu erhöhen. Können Sie versuchen, nacheinander "core.client.module.js" und "core.client.routes.js" zu deaktivieren, um zu sehen, welche funktioniert und welche immer noch fehlschlägt? – shershen

+1

Sie haben es versäumt, 'core.client.module.js' Funktion auszuführen, sollte es' (function() {...........})() ', im Grunde müssen Sie die Funktion aufrufen, um aufgerufen zu werden es sofort –

+0

@shershen habe ich das und es ist der Grund Kern Ursache ngRoute funktioniert gut. –

Antwort

1

Da Sie das Muster IIFE zur Einschränkung des Codeumfangs verwendet haben, sollten Sie die Funktion core.client.module.js sofort auf core Modul abrufen.

core.client.module.js

(function(){ 

    //---- code here-----// 

})(); //<---invoke the function