javascript 模块“ngRoute”不可用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30719722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Module 'ngRoute' is not available
提问by AJ Larson
I have linked the script in my index.html, and referenced it in app.js, but I keep getting the error that ngRoute is not available. Any help would be greatly appreciated!
我已经在我的 index.html 中链接了脚本,并在 app.js 中引用了它,但我不断收到 ngRoute 不可用的错误。任何帮助将不胜感激!
app.js
应用程序.js
angular.module('gameMaster', ['ngRoute', 'castServices']);
.config
.config
angular.module('gameMaster')
.config(function($routeProvider, $locationProvider){
$routeProvider
//welcome page
.when('/welcome', {
templateUrl: '../../../../pages/welcome.html',
controller: 'gameController'
})
//gameplay page
.when('/gameplay',{
templateUrl: '../../../../pages/gameplay.html',
controller: 'gameController'
})
//default to welcome
.otherwise({
redirectTo: '/welcome'
});
$locationProvider.html5mode(true);
});
index.html
索引.html
<html>
<head>
<title>Party Things!</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-route.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
<script type="text/javascript" src="node_modules/underscore/underscore.js"></script>
<script type="text/javascript" src="js/modules/castServices/castServices.js"></script>
<script type="text/javascript" src="js/modules/gameMaster/app.js"></script>
</head>
Does anything jump out at you?
有什么东西向你扑来吗?
Thanks!
谢谢!
采纳答案by AJ Larson
It turns out that I had caching issues. I went into the developer options and disabled cache while the pane was open, and viola. Thanks for your help!
事实证明我有缓存问题。当窗格打开时,我进入了开发人员选项并禁用了缓存,中提琴。谢谢你的帮助!
回答by Tamara
Just for the record. Now Angular distributes ngRoute module as a separate file - http://docs.angularjs.org/api/ngRoute
只是为了记录。现在 Angular 将 ngRoute 模块作为一个单独的文件分发 - http://docs.angularjs.org/api/ngRoute
You need to download angular-route.js and include in your webpage:
您需要下载 angular-route.js 并将其包含在您的网页中:
<script src="angular.js">
<script src="angular-route.js">