简体   繁体   English

AngularJs错误:[$ injector:modulerr]由ngRoute提供?

[英]AngularJs Error: [$injector:modulerr] by ngRoute?

Probably a dupicate ( Failed to instantiate module error in Angular js ) but the given measures (including ng-route in HTML didn't solve the problem). 可能是重复的( 在Angular js中无法实例化模块错误 ),但是给定的度量(包括HTML中的ng-route不能解决问题)。

This is the error: 这是错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module coursemate due to: Error: [$injector:nomod] Module 'coursemate' is not available! 未被捕获的错误:[$ injector:modulerr]由于以下原因而无法实例化模块的同学:错误:[$ injector:nomod]模块'coursemate'不可用! 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. 如果注册模块,请确保将依赖项指定为第二个参数。

this is my app.js 这是我的app.js

 var coursemate = angular.module('coursemate', ["ngRoute"]); coursemate.config(function($routeProvider) { $routeProvider .when("/", { templateUrl : "view1.html" }) .otherwise({ redirectTo : '/' }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 

this is my index.html 这是我的index.html

 <!DOCTYPE html> <html lang="de" ng-app="coursemate"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>CourseMate</title> <base href="/CourseMate/" /> <!-- Font Awesome --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css"> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Material Design Bootstrap --> <link href="css/mdb.min.css" rel="stylesheet"> <!-- Your custom styles (optional) --> <link href="css/style.css" rel="stylesheet"> </head> <body> <ng-view> </ng-view> </body> <!-- SCRIPTS --> <!-- JQuery --> <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script> <!-- Bootstrap tooltips --> <script type="text/javascript" src="js/tether.min.js"></script> <!-- Bootstrap core JavaScript --> <script type="text/javascript" src="js/bootstrap.min.js"></script> <!-- MDB core JavaScript --> <script type="text/javascript" src="js/mdb.min.js"></script> <!-- AngularJS reditect --> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script> <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.js"></script>--> <script src="https://cdn.socket.io/socket.io-1.4.5.js"></script> <script src="/app.js"></script> </html> 

I can not find my mistake as I don't think that I have initialized the app in a wrong way? 我找不到错误,因为我不认为我以错误的方式初始化了应用程序?

Remove the " ; " after redirectTo: '/'. 在redirectTo:'/'之后删除“ ; ”。 And make sure that you have all your reference in your CourseMate directory. 并确保在CourseMate目录中拥有所有参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM