[英]Angular - Module not found
I have tried to create an angular application using ui-router. 我试图使用ui-router创建一个角度应用程序。
In HTML file I have this in the body element: 在HTML文件中,我在body元素中有这个:
<div class="container" ng-app="ang">
<header ng-include="'templates/head.html'"></header>
<div ui-view></div>
<footer ng-include="'templates/foot.html'"></footer>
</div>
<script src="Dependencies/jquery-1.11.3.min.js"></script>
<script src="Dependencies/angular-ui-router.min.js"></script>
<script src="Dependencies/angular.js"></script>
<script src="js/ang.js"></script>
In the module, I have this: 在模块中,我有这个:
angular.module('ang', ['ui-router'])
But Chrome gives me out this error: 但是Chrome给了我这个错误:
Uncaught TypeError: Cannot read property 'isDefined' of undefined(anonymous function) @ angular-ui-router.min.js:7(anonymous function) @ angular-ui-router.min.js:7
angular.js:80 Uncaught Error: [$injector:modulerr] Failed to instantiate module ang due to:
Error: [$injector:nomod] Module 'ang' 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.0/$injector/nomod?p0=ang
at REGEX_STRING_REGEXP (file:///home/user/Desktop/ang/Dependencies/angular.js:80:12)
at file:///home/user/Desktop/ang/Dependencies/angular.js:1797:17
at ensure (file:///home/user/Desktop/ang/Dependencies/angular.js:1721:38)
at module (file:///home/user/Desktop/ang/Dependencies/angular.js:1795:14)
at file:///home/user/Desktop/ang/Dependencies/angular.js:4064:22
at forEach (file:///home/user/Desktop/ang/Dependencies/angular.js:335:20)
at loadModules (file:///home/user/Desktop/ang/Dependencies/angular.js:4048:5)
at createInjector (file:///home/user/Desktop/ang/Dependencies/angular.js:3974:11)
at doBootstrap (file:///home/user/Desktop/ang/Dependencies/angular.js:1484:20)
at bootstrap (file:///home/user/Desktop/ang/Dependencies/angular.js:1505:12)
http://errors.angularjs.org/1.3.0/$injector/modulerr?p0=ang&p1=Error%3A%20%…F%2F%2Fhome%2Fuser%2FDesktop%2Fang%2FDependencies%2Fangular.js%3A1505%3A12)
How can I fix this? 我怎样才能解决这个问题?
As you are using ng-app="ang"
define module as 当您使用
ng-app="ang"
定义模块时
angular.module('ang', ['ui-router'])
instead of 代替
angular.module('app', ['ui-router'])
Change the sequence of these files as angular.js
should be loaded before angular-ui-router.min.js
更改这些文件的顺序,因为
angular.js
应该在angular-ui-router.min.js
之前加载
<script src="Dependencies/angular.js"></script>
<script src="Dependencies/angular-ui-router.min.js"></script>
You need to add the angular-ui-router.min.js
file after the angular.js
file, 你需要在
angular-ui-router.min.js
文件之后添加angular-ui-router.min.js
angular.js
文件,
<script src="Dependencies/angular.js"></script>
<script src="Dependencies/angular-ui-router.min.js"></script>
And define the dependency like ui.router
not the ui-router
. 并定义依赖项,如
ui.router
而不是ui-router
。
angular.module('ang', ['ui.router']);
您的角度脚本引用应出现在angular-ui-router脚本引用之前。
<script src="Dependencies/angular.js"></script> <script src="Dependencies/angular-ui-router.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.