2016-04-07 10 views
1

を注入したとき、私は1.5.3の角度を使用しますが、私は「ngRouteは」私はこのようなエラーを得注入する場合:ここでエラーngRoute

angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.3/ $injector/modulerr?p0=scotchApp&p1=Error%…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.3%2Fangular.min.js%3A20%3A463)(anonymous function) @ angular.js:38(anonymous function) @ angular.js:4547q @ angular.js:321g @ angular.js:4508eb @ angular.js:4430c @ angular.js:1710yc @ angular.js:1731de @ angular.js:1616(anonymous function) @ angular.js:30709b @ angular.js:3127Pf @ angular.js:3417Of.d @ angular.js:3405

はコード

var scotchApp = angular.module('scotchApp', ['ngRoute']); 
    scotchApp.config(function($routeProvider) { 
     $routeProvider 
      .when('/', { 
       templateUrl : 'home.html', 
       controller : 'mainController' 
      }) 
      .when('/about', { 
       templateUrl : 'about.html', 
       controller : 'aboutController' 
      }) 
      .when('/contact', { 
       templateUrl : 'contact.html', 
       controller : 'contactController' 
      }); 
    }); 
    scotchApp.controller('mainController', function($scope) { 
     // create a message to display in our view 
     $scope.message = 'Everyone come and see how good I look!'; 
    }); 
    scotchApp.controller('aboutController', function($scope) { 
     $scope.message = 'Look! I am an about page.'; 
    }); 
    scotchApp.controller('contactController', function($scope) { 
     $scope.message = 'Contact us! JK. This is just a demo.'; 
    }); 
</script> 
</head> 
<body ng-controller="mainController"> 
    <div id="main"> 
     <div ng-view></div> 
    </div> 
</body> 
</html> 

である私はそれ

を解決してください

ありがとう

+1

'angle-route.js'をindex.htmlファイルに追加しましたか?正しい順序で追加しましたか? – M22an

+0

angular.jsの非圧縮バージョンを使用すると、デバッグに役立ちます – jithin

答えて

0

モジュールngRouteは、主要な角形スクリプトにありません。それはangular-route.jsにあります。あなたのページにこのスクリプトを含めてください。

<script src="angular.js"> 
<script src="angular-route.js"> 

1.5.3用docsによると:

You can download this file from the following places:

where X.Y.Z is the AngularJS version you are running.

は詳細についてはngRouteためdocsを参照してください。

+0

ありがとう、私はそれを試してみるつもりですか? – user1186850

+0

私はそれを追加しましたが、私はまだこのエラーがあります – user1186850

関連する問題