错误ngRoute不可用(Error ngRoute is not available)

编程入门 行业动态 更新时间:2024-10-27 12:37:38
错误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标题:

<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.

更多推荐

本文发布于:2023-07-24 00:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1239150.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不可用   错误   ngRoute   Error

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!