2016-04-09 13 views
1

私はこのメインアプリケーションをダッシュ​​ボードといい、コアと呼ばれるカスタムメイドのモジュールを挿入したいと思います。

私はこの注入エラーが発生し続けているのですが、私はその理由を知りません。私は、私の同僚が持っているテンプレートに従っています。それは言葉の言葉が大ですので、なぜ私にとってうまくいかないのかわかりません。

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 

    } 




}); 

コンソールエラー:

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

。 core.client.module.jsと 'core.client.routes.js'のどちらを使用して無効にすることができますか? – shershen

+1

あなたは 'core.client.module.js'関数を実行するのを見逃しました。'(function(){...........})() 'は、基本的に呼び出す関数を呼び出す必要がありますそれはすぐに –

+0

@ shershen私はそれをして、それは確かにコアの原因ngRouteうまく動作します。 –

答えて

1

コード範囲を制限するためにIIFEパターンを使用していたので、すぐにcore.client.module.jsという関数を呼び出すと、coreモジュールが入手可能になります。それがエラーを上げされたmodile不明だスタックトレースから

core.client.module.js

(function(){ 

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

})(); //<---invoke the function 
関連する問題