无法加载ngRoute模块
我正在使用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合作,所以对此的任何想法都非常感谢!
这只是一个错字(缺less等号)。 这一行:
<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
脚本中有一个很小的错字。 你有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>
您可以通过检查开发人员工具并确保脚本加载没有错误来debugging这些types的问题。
- webdrivererror:连接重置
- Angular2与TypeScript:声明预期编译器错误@component后
- 错误,当我部署ng build –prod Angular 4.3.2
- 在Angular 2中使用JS库xml2js
- 当为一个npm模块使用一个私有的git url时,如何configuration消费应用程序只使用模块的dist文件夹中的文件?
- 量angular器testingmeanJSpipe理页面?
- Angular Cli代理在一个env中工作,但在另一个环境中返回ECONNRESET
- Angular2的components.map不是一个函数
- “ng2-CKEditor”节点模块不能使用打印机