2016-08-17 23 views
1

モジュールをインスタンス化できないようです。ここに私のファイルです:モジュールエラー角度1.5

--tv 
    -- contents (folder) 
     -- contents.template.html 
     -- contents.component.js 
    -- index.html 
    -- bootstrap.js 

は今、ここでのコードは次のとおりです。

Contents.component.js:

angular 
.module('contents', []) 
.component('myContents', { 
    controller: contentController, 
    templateUrl: 'contents/content.template.html', 


}); 
function contentController() { 
console.log('Le content est appelée !'); 
} 

のindex.html:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <base href="/"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/css/bootstrap.min.css" integrity="sha384-MIwDKRSSImVFAZCVLtU0LMDdON6KVCrZHyVQQj6e8wIEJkW4tvwqXrbMIya1vriY"    crossorigin="anonymous"> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 
    <title>TV</title> 
    <!-- SCRIPT DE CONNEXION --> 
    <script src="bower_components/angular/angular.js"></script> 
    <script src="bootstrap.js"></script> 
    <script src="/bower_components/angular-component-router/angular_1_router.js"></script> 
    <script src="/bower_components/angular-component-router/ng_route_shim.js"></script> 
    <script src"/contents/contents.component.js"></script> 


</head> 
<body ng-app="app"> 
    <my-contents></my-contents> 

    <!-- jQuery library --> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" integrity="sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY" crossorigin="anonymous"></script> 
    <!-- Tether --> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js" integrity="sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB" crossorigin="anonymous"></script> 
    <!-- Latest compiled JavaScript --> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/js/bootstrap.min.js" integrity="sha384-ux8v3A6CPtOTqOzMKiuo3d/DomGaaClxFYdCu2HPMBEkf6x2xiDyJ7gkXU0MWwaD" crossorigin="anonymous"></script> 
</body> 
</html> 

最後にbootstrap.js :

angular 
.module('app', ['ngComponentRouter', 'contents']) 
.config(function ($locationProvider) { 
    $locationProvider.html5Mode(true); 
}) 
.value('$routerRootComponent', 'myApp') 
.component('app', { 

}); 

やブラウザのコンソールにcatchedエラー:作品

私は私が構築され、他のプロジェクトのコピー/ペーストを作っ
Error: [$injector:modulerr] Failed to instantiate module app due to: 
[$injector:modulerr] Failed to instantiate module contents due to: 
[$injector:nomod] Module 'contents' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 
http://errors.angularjs.org/1.5.8/$injector/nomod?p0=contents 
minErr/<@http://127.0.0.1:8080/bower_components/angular/angular.js:68:12 
module/<@http://127.0.0.1:8080/bower_components/angular/angular.js:2082:17 
[email protected]://127.0.0.1:8080/bower_components/angular/angular.js:2006:38 
[email protected]://127.0.0.1:8080/bower_components/angular/angular.js:2080:14 
loadModules/<@http://127.0.0.1:8080/bower_components/angular/angular.js:4617:22 
[email protected]://127.0.0.1:8080/bower_components/angular/angular.js:321:11 
[email protected]://127.0.0.1:8080/bower_components/angular/angular.js:4601:5 
loadModules/<@http://127.0.0.1:8080/bower_components/angular/angular.js:461 

昨日。なぜそれが機能していないのか分かりません。

+0

salut、他にはどんなエラーがありますか? – DMCISSOKHO

+0

'index.html'の' bootstrap.js'のスクリプトタグの上に 'contents.component.js'のスクリプトタグを移動します – Jag

+0

Cissokho hein? :Pサルート! 私は、何も変わらないように見えました! –

答えて

1

あなたのアプリをブートストラップしてから、contentsスクリプトを読み込みます。次のような注文を変更してください:

<script src="bower_components/angular/angular.js"></script> 
<script src="/bower_components/angular-component-router/angular_1_router.js"></script> 
<script src="/bower_components/angular-component-router/ng_route_shim.js"></script> 
<script src"/contents/contents.component.js"></script> 
<script src="bootstrap.js"></script> 
+0

bootstrap.jsは単なる名前で、すべてのブートストラップの情報はindex.htmlの最後にありますか? –

+0

bootstrapは角の初期化プロセスです – DMCISSOKHO

+0

bootstrap.jsはモジュールを宣言するファイルです。ライブラリファイル(angleやjQueryなど)が先に来てからアプリの.jsファイルが最初に来るはずです。 – AranS

関連する問題