2016-09-21 8 views
-1

これらの質問は数百万件あり、私はAngularJSでしばらくコーディングしていましたが、これは珍しいことです。

2週間前私はクライアント用のウェブサイトを展開し、すべてが美しく動作していました。その後、クライアントは小さな変更が必要だと判断したので、変更を加える前に、ローカルサーバー上でウェブサイトを実行して、すべてが正常であることを確認しました。

次に、このエラーがポップアップします。私はそれが何を意味するのかわからないし、コードに何も変更を加えていません。これは完璧に動作する配備されたサイトと同じです。万が一、このエラーの意味を知っている人はいますか?

Failed to instantiate module crsportal due to: 
Error: [$injector:modulerr] http://errors.angularjs.org/1.5.7/$injector/modulerr?p0=c...) 
    at Error (native) 
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:6:412 
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:40:134 
    at r (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:7:355) 
    at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:39:222) 
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:39:391 
    at r (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:7:355) 
    at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:39:222) 
    at db (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:43:246) 
    at c (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:20:359 

おそらく私はそれを実現することなく何かを変更したので、あなたにコードを与えることができます。

crsportal.js

(function() { 
    'use strict'; 

    angular 
    .module('crsportal', [ 
     'crs.authentication', 
     'crs.config', 
     'crs.routes', 
     'crs.profiles.controllers', 
     'profile.services', 
     'route.controller' 
    ]); 

    angular 
    .module('crs.config', []); 

    angular 
    .module('crs.profiles.controllers', []); 

    angular 
    .module('crs.routes', ['ngRoute']); 

    angular 
    .module('profile.services', []); 

    angular 
    .module('route.controller', []); 

    angular 
    .module('crsportal') 
    .run(run); 

    run.$inject = ['$http']; 

    /** 
    * @name run 
    * @desc Update xsrf $http headers to align with Django's defaults 
    */ 
    function run($http) { 
     $http.defaults.xsrfHeaderName = 'X-CSRFToken'; 
     $http.defaults.xsrfCookieName = 'csrftoken'; 
    } 

})(); 

index.htmlを

<!DOCTYPE html> 
<html> 
<head> 
    <title>CRS Client Portal</title> 

    <base href="/" /> 

    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 

    <!-- The HTML5 Shim is required for older browsers, mainly older versions IE --> 
    <!--[if lt IE 9]> 
     <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> 
    <![endif]--> 
    <!--[if lt IE 7]> 
    <div style=' clear: both; text-align:center; position: relative;'> 
     <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" alt="" /></a> 
    </div> 
    <![endif]--> 

    <script> 
     (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 
     (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 
     m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 
     })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); 

     ga('create', 'UA-84093208-1', 'auto'); 
     ga('send', 'pageview'); 
    </script> 
    {% include 'stylesheets.html' %} 
    <!-- Latest compiled and minified CSS --> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
</head> 

<body ng-app="crsportal" class="loginpage"> 
    <div class="container-fluid" ng-controller="LoginController as vm"> 
     {% include 'login.html' %} 
    </div> 

    {% include 'javascripts.html' %} 
</body> 
</html> 

編集:追加情報

authentication.module.js

(function() { 
    'use strict'; 
    angular 
    .module('crs.authentication', [ 
     'authentication.controllers', 
     'authentication.services' 
    ]); 

    angular 
    .module('authentication.controllers', []); 

    angular 
    .module('authentication.services', ['ngCookies']); 
})(); 

javascripts.html

<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script> 
<script type="text/javascript" src="{% static 'bower_components/bootstrap-material-design/dist/js/material.js' %}"></script> 
<script type="text/javascript" src="{% static 'bower_components/bootstrap-material-design/dist/js/ripples.js' %}"></script> 
<script type="text/javascript" src="{% static 'bower_components/underscore/underscore.js' %}"></script> 

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-route.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-cookies.js"></script> 


<script type="text/javascript" src="{% static 'bower_components/ngDialog/js/ngDialog.js' %}"></script> 
<script type="text/javascript" src="{% static 'lib/snackbarjs/snackbar.min.js' %}"></script> 

<script type="text/javascript" src="{% static 'javascripts/crsportal.js' %}"></script> 

<script type="text/javascript" src="{% static 'javascripts/config.js' %}"></script> 
<script type="text/javascript" src="{% static 'javascripts/routes.js' %}"></script> 
<script type="text/javascript" src="{% static 'javascripts/authentication/authentication.module.js' %}"></script> 
<script type="text/javascript" src="{% static 'javascripts/authentication/services/authentication.services.js' %}"></script> 
<script type="text/javascript" src="{% static 'javascripts/authentication/controllers/login.controller.js' %}"></script> 
<script type="text/javascript" src="{% static 'javascripts/authentication/controllers/logout.controller.js' %}"></script> 
+1

エラー:[$インジェクター:modulerr] http://errors.angularjs.org/1.5.7/$injector/modulerr?p0=cを:この作品を示し

//i added this angular.module('crs.authentication', []); angular .module('crs.config', []); angular .module('crs.profiles.controllers', []); //make sure no other module references ngRoute or this could be a problem as well. if it does add it as a depenency angular .module('crs.routes', ['ngRoute']); angular .module('profile.services', []); angular .module('route.controller', []); //i moved this to last angular .module('crsportal', [ 'crs.authentication', 'crs.config', 'crs.routes', 'crs.profiles.controllers', 'profile.services', 'route.controller' ]); 

フィドル。 ..)この完全なURLは何ですか? – NicolasMoise

+0

角度モジュールの1つが見つかりません。あなたはどれを見つけなければなりません。 – NicolasMoise

+0

http://errors.angularjs.org/1.5.7/$injector/modulerr?p0=crs.authentication&p1=Error%3A%20%5B%24injector%3Anomod%5D%20http%3A%2F%2Ferrors.angularjs。 org%2F1.5.7%2F%24injector%2Fnomod%3Fp0%3Dcrs.authentication%0A%20%20%20%20at%20Error%20(ネイティブ)%0A%20%20%20%20at%20https%3A%2F %2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.7%2Fangular.min.js%3A6%3A412%0A%20%20%20%20at%.....(リンク全体を含めるには長すぎます) –

答えて

-1

あなたはそれはあなたが

angular 
    .module('crsportal', [ 
     'crs.authentication', 
     'crs.config', 
     'crs.routes', 
     'crs.profiles.controllers', 
     'profile.services', 
     'route.controller' 
    ]); 

AngularJS: Uncaught Error: [$injector:modulerr] Failed to instantiate module?

を参照してくださいを実行する時間によってインスタンス化されていない "crs.authentication" モジュールが欠落しています
+1

申し訳ありませんが、あなたはそれが何を意味するか分かりません。このリンクには、スクリプトの後に誰かがangular.jsをロードする問題が記述されています。私は何かが欠けていない限り、これは同じ問題ではありません。 –

+0

Angularは、モジュールを順不同でロードできます。 – Phil

+0

@Phil rightしかし、あなたは本当にそれがこのような状況にあると思いますか? –

-1

の定義があることを確認してくださいhttp://jsfiddle.net/ncapito/ku3c33bj/

+0

これは完全に間違っています – Phil

+0

私は修正することができるように精巧にしてください。 – Nix

+0

モジュールは特定の順序で定義する必要はありません。モジュールが構成されて実行される前に、Angularが依存関係ツリーを処理します。 – Phil

関連する問題