Angular 1.4.5 : Uncaught Error: [$injector:modulerr] ngRoute
Angular 1.4.5 : Uncaught Error: [$injector:modulerr] ngRoute
当我尝试刷新页面时,我有这个错误:
angular.js: http://errors.angularjs.org/1.4.5/38美元喷射器/modulerr ?
p0 = myApp& p1 3 =错误% % 2…ogleapis.com % 2 fajax % 2 flibs % 2 fangularjs % 2 f1.4.5 % 2 fangular.min.js % 3 a19 % 3 a381)
我有一个简单的模块,依赖于ngRoute:
var app = angular.module('myapp', ["ngRoute"]);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl :'pages/main.html',
controller : 'mainController'
})
.when('/second',{
templateUrl : 'pages/second.html',
controller : 'secondController'
})
});
和我的HTML代码
<html ng-app='myApp'>
<head><title>The title</title></head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5
/angular.min.js"></script>
<script src="https://code.angularjs.org/1.4.5/angular-route.js">
<script src="app.js"></script>
</script>
<body>
<div ng-view>
</div>
</body>
</html>
基本上是排版错误。
应该是
<html ng-app='myapp'>
代替
<html ng-app='myApp'>
另外更正你的脚本标签如下。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://code.angularjs.org/1.4.5/angular-route.js"></script>
<script src="app.js"></script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function( $routeProvider ) {
$routeProvider
.when("/home", {
template : "<h1>Main</h1><p>Click on the links to change this content</p>"
})
.when("/red", {
templateUrl : "red.htm"
})
.when("/green", {
templateUrl : "green.htm"
})
.when("/blue", {
templateUrl : "blue.htm"
});
});
在我的情况下,我使用$routeProvider.when({})
没有url作为第一个参数,情况就是这样,当我像下面这样添加url时,错误消失了。
$routeProvider.when('/post/:id', {
templateUrl: 'views/post.html',
controller: 'PostController'
})
相关文章:
- 错误:$injector:modulerr模块错误(我的第一个SPA应用程序)
- 错误:$injector:modulerr加载图像时模块处于角度
- ng路由injectore:modulerr中出错[$injector:modulerr]http://errors.a
- 未捕获的错误: [$injector:modulerr] http ..(使用纯 HTML)
- 未捕获的错误:使用 ng-repeat 时出现 [$injector:modulerr]
- 未捕获的错误: [$injector:modulerr] - 角度 ng-include
- Error $injector:modulerr AngularJs
- Angularjs未捕获错误:迁移到V1.3时出现[$injector:modulerr]
- $injector:modulerr将自定义模块注入Angular应用程序
- 未捕获错误:[$injector:modulerr](新手)
- AngularJS错误:$injector:modulerr我的浏览器窗口中出现模块错误
- 获取未捕获错误:anuglar.js中的[$injector:modulerr]
- Angular应用程序无法安装,原因是出现错误:[$injector:modulerr]
- AngularJS - $injector:modulerr 模块错误在 angular.js:36.
- 未捕获的错误: [$injector:modulerr] 无法实例化模块 toastr
- Angularjs Error: [$injector:modulerr] 'ngRoute'
- 角度 JavaScript 缩小导致错误:$injector:modulerr 模块错误
- Injector:modulerr in the config (newbie)
- Angular js 未捕获错误:[$injector:modulerr] 匿名函数
- AngularJS : 未捕获错误: [$injector:modulerr] 使用 angularJS 的更新版本时