错误 ngRoute 不可用
Error ngRoute is not available
控制台出现错误
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.
这是我的 index.html header :
<script src="scripts/jquery-2.0.3.min.js" type="text/javascript"></script>
<script src="scripts/libs/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.js" type="javascript"></script>
<script src="scripts/app.js" type="text/javascript"></script>
</head>
这是我的 app.js :
var app = angular.module('myapp', ['ngRoute']);
app.config(function($routeProvider){
$routeProvider
.when('/queueManager', {
templateUrl: '/templates/page/queueManager.html',
controller: 'QCtrl'
});
});
app.controller('QCtrl',['$http','$interval','$scope', function($http, $interval,$scope){
this.queues = queue;
var store = this;
store.queues = [];
var queue = [];
$http.get('/queue/info').success(function(data) {
store.queues = data;
});
});
这是我的 routes.js :
angular.module("myapp", ['ngRoute'])
.config(function($routeProvider){
$routeProvider.when('/queueManager', {
templateUrl: '/templates/page/queueManager.html'
})
});
在 chrome 的开发工具中,文件显示为已加载,看来我拼写正确...
我仍然遇到与之前提到的相同的错误。每次我在 Whosebug 上搜索时,如果你将它添加到你的 html 中,它是相同的答案检查...
你有解决我的问题的方法吗?
编辑:在 app.js 中添加了 app.config 并将路由模块名称更改为我的应用程序。并添加了编辑
谢谢
您需要将 "AchApp" 模块添加为 'myapp' 模块的依赖项。
所以你的 app.js
看起来像:
var app = angular.module('myapp', ['ngRoute', "AchApp"]);
app.controller('QCtrl',['$http','$interval','$scope', function($http, $interval,$scope){
this.queues = queue;
var store = this;
store.queues = [];
var queue = [];
$http.get('/queue/info').success(function(data) {
store.queues = data;
});
});
终于找到错误了....
我的脚本类型是 "javascript" 而不是 "text/javascript"。有史以来最好的错误......
顺便感谢您的回答。
控制台出现错误
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.
这是我的 index.html header :
<script src="scripts/jquery-2.0.3.min.js" type="text/javascript"></script>
<script src="scripts/libs/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.js" type="javascript"></script>
<script src="scripts/app.js" type="text/javascript"></script>
</head>
这是我的 app.js :
var app = angular.module('myapp', ['ngRoute']);
app.config(function($routeProvider){
$routeProvider
.when('/queueManager', {
templateUrl: '/templates/page/queueManager.html',
controller: 'QCtrl'
});
});
app.controller('QCtrl',['$http','$interval','$scope', function($http, $interval,$scope){
this.queues = queue;
var store = this;
store.queues = [];
var queue = [];
$http.get('/queue/info').success(function(data) {
store.queues = data;
});
});
这是我的 routes.js :
angular.module("myapp", ['ngRoute'])
.config(function($routeProvider){
$routeProvider.when('/queueManager', {
templateUrl: '/templates/page/queueManager.html'
})
});
在 chrome 的开发工具中,文件显示为已加载,看来我拼写正确... 我仍然遇到与之前提到的相同的错误。每次我在 Whosebug 上搜索时,如果你将它添加到你的 html 中,它是相同的答案检查... 你有解决我的问题的方法吗?
编辑:在 app.js 中添加了 app.config 并将路由模块名称更改为我的应用程序。并添加了编辑
谢谢
您需要将 "AchApp" 模块添加为 'myapp' 模块的依赖项。
所以你的 app.js
看起来像:
var app = angular.module('myapp', ['ngRoute', "AchApp"]);
app.controller('QCtrl',['$http','$interval','$scope', function($http, $interval,$scope){
this.queues = queue;
var store = this;
store.queues = [];
var queue = [];
$http.get('/queue/info').success(function(data) {
store.queues = data;
});
});
终于找到错误了....
我的脚本类型是 "javascript" 而不是 "text/javascript"。有史以来最好的错误......
顺便感谢您的回答。