在控制台中有我的错误
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标题:
<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的开发工具中,文件显示为已加载,似乎我拼写正确...我仍然得到与之前提到的相同的错误。 每次我在stackoverflow上搜索,如果你在你的HTML中添加它,它是相同的答案检查...你有一些关于我的问题的解决方案吗?
编辑:在app.js中添加app.config并将路径模块名称更改为我的应用程序。 并添加了编辑
谢谢
there is my error in console
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.
this is my 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>this is my 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; }); });And this is my routes.js :
angular.module("myapp", ['ngRoute']) .config(function($routeProvider){ $routeProvider.when('/queueManager', { templateUrl: '/templates/page/queueManager.html' }) });In dev tools from chrome, files appears as loaded, and it seems that i spelled it right... An I still get the same error as mentioned before. Every time i search on stackoverflow, it's the same answer check if you added it in your html... Have you some solution about my problem ?
Edit : Added app.config in app.js and changed routes module name to my app. And added edit
Thank you
最满意答案
您需要将“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; }); });I finally found my mistake....
My script type was "javascript" and not "text/javascript". Best mistake ever ...
Thanks for your answer by the way.
更多推荐
发布评论