admin管理员组文章数量:1401664
I'm new to AngularJS. Although it is a simple problem, I have found similar error but cause was different.
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:nomod] Module 'myApp' 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.
I have index.html file:
<html ng-app="myApp">
<head>
<title>Module example</title>
<script src=".4.4/angular.js"></script>
<script src=".4.4/angular-route.js"></script>
<script src="app.js" type="text/javascript"/>
</head>
<body>
2 + 2 = {{2 + 2}}
</body>
my app.js file is:
angular.module('myApp', []);
All files were loaded:
Could you help me guys to resolve this simple issue.
I'm new to AngularJS. Although it is a simple problem, I have found similar error but cause was different.
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:nomod] Module 'myApp' 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.
I have index.html file:
<html ng-app="myApp">
<head>
<title>Module example</title>
<script src="https://ajax.googleapis./ajax/libs/angularjs/1.4.4/angular.js"></script>
<script src="https://ajax.googleapis./ajax/libs/angularjs/1.4.4/angular-route.js"></script>
<script src="app.js" type="text/javascript"/>
</head>
<body>
2 + 2 = {{2 + 2}}
</body>
my app.js file is:
angular.module('myApp', []);
All files were loaded:
Could you help me guys to resolve this simple issue.
Share Improve this question asked Jan 11, 2016 at 19:30 migAlexmigAlex 3733 silver badges16 bronze badges 1- 2 try <script src="app.js" type="text/javascript"><script/> instead of <script src="app.js" type="text/javascript"/> – Julien Roy Commented Jan 11, 2016 at 19:32
3 Answers
Reset to default 6Change
<script src="app.js" type="text/javascript"/>
to:
<script src="app.js" type="text/javascript"></script>
your tag script is not closed right, it must be:
<script src="app.js" type="text/javascript"></script>
Guy, you have forgotten to close your script tag ! And your html tag ! And your doctype !
Try :
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>Module example</title>
<script src="https://ajax.googleapis./ajax/libs/angularjs/1.4.4/angular.js"></script>
<script src="https://ajax.googleapis./ajax/libs/angularjs/1.4.4/angular-route.js"></script>
<script src="app.js" type="text/javascript"></script>
</head>
<body>
2 + 2 = {{2 + 2}}
</body>
</html>
And it will works ...
Take a look at https://validator.w3 before asking here, please.
本文标签: javascriptAngularJS module 39myApp39 is not availableStack Overflow
版权声明:本文标题:javascript - AngularJS module 'myApp' is not available - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744260580a2597696.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论