gpt4 book ai didi

javascript - AngularJs错误: [$injector:modulerr] by ngRoute?

转载 作者:行者123 更新时间:2023-12-03 04:18:55 27 4
gpt4 key购买 nike

可能是重复的( Failed to instantiate module error in Angular js ),但给定的措施(包括 HTML 中的 ng-route 并没有解决问题)。

这是错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module coursemate due to: Error: [$injector:nomod] Module 'coursemate' 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.

这是我的 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>

这是我的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>

我找不到我的错误,因为我认为我没有以错误的方式初始化应用程序?

最佳答案

删除redirectTo: '/'后的“;”。并确保您的 CourseMate 目录中包含所有引用资料。

关于javascript - AngularJs错误: [$injector:modulerr] by ngRoute?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44033729/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com