无法加载ngRoute模块
Unable to load ngRoute module
我正在开发一个使用Angular的Node.js项目,并尝试实现多个视图和路由。我已经按照这里概述的说明安装angular-route.js文件和相关模块:
https://docs.angularjs.org/api/ngRoute
但我仍然在控制台中收到这个错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module blogApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
Error: [$injector:nomod] Module 'ngRoute' 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.3.20/$injector/nomod?p0=ngRoute
以下是与我的控制器和HTML文件相关的部分:
app.js
var blogApp = angular.module('blogApp', ['ngRoute']);
index.html
<!DOCTYPE html>
<html ng-app="blogApp">
<head>
<title>Blog Posts</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- styles -->
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="stylesheets/style.css" rel="stylesheet" media="screen">
</head>
<body ng-controller="postController">
// page content
<!-- scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular.js"></script>
<script src"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
<script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript"></script>
<script src="javascripts/app.js"></script>
</body>
</html>
我是Angular和Node的新手,所以非常感谢对此的任何想法!
这只是一个拼写错误(缺少等号)。此行:
<script src"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
应为:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
ngRoute
的include脚本中有一个非常小的拼写错误。你有src"https://
而不是src="https://
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular-route.js"></script>
<script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript"></script>
<script src="javascripts/app.js"></script>
您可以通过检查开发人员工具并确保加载的脚本没有错误来调试这类问题。
相关文章:
- Javascript,访问一个主要对象模块模式中的每个对象
- 节点Js:How to catch a“;没有这样的文件或目录“;读取线模块出错
- 如何从模块链中调用函数.导出到节点中
- 尽管链接成功并已成功下载,但未找到NPM模块
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- 从模块内部访问Express装载路径
- RequireJS向模块传递配置总是返回undefined
- Node.js正在更改应用程序以使用集群模块
- 在Meteor项目中安装并包含npm模块后出错
- 模块模式和这个
- 将依赖外部库的UMD模块与browserfy捆绑在一起
- 找不到模块捆绑包
- JavaScript命名约定;静态“;类或模块
- 显示模块模式在Knockout中设置模型的新实例
- 有没有比在app.js上绑定模块名称更好的方法来动态加载视图模型和视图以显示模态
- NgRoute未加载(模块错误)
- 与 ngRoute 的模块依赖会破坏角度渲染
- ngHide 指令仅在页面刷新后与 ngRoute 模块一起使用
- 无法加载ngRoute模块
- Angular js错误:[$injector:modulerr]实例化ngroute模块失败,原因是: