Error: [$injector:nomod] Module 'dayApp' is not available!

来源:互联网 发布:工厂生产数据表格 编辑:程序博客网 时间:2024/06/05 00:31

1、错误描述

angular.js:4920 Uncaught Error: [$injector:modulerr] Failed to instantiate module dayApp due to:Error: [$injector:nomod] Module 'dayApp' 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.6.3/$injector/nomod?p0=dayApp    at http://192.168.0.175:8020/AngularJS/js/angular.js:66:12    at http://192.168.0.175:8020/AngularJS/js/angular.js:2257:17    at ensure (http://192.168.0.175:8020/AngularJS/js/angular.js:2178:38)    at module (http://192.168.0.175:8020/AngularJS/js/angular.js:2255:14)    at http://192.168.0.175:8020/AngularJS/js/angular.js:4896:22    at forEach (http://192.168.0.175:8020/AngularJS/js/angular.js:402:20)    at loadModules (http://192.168.0.175:8020/AngularJS/js/angular.js:4880:5)    at createInjector (http://192.168.0.175:8020/AngularJS/js/angular.js:4802:19)    at doBootstrap (http://192.168.0.175:8020/AngularJS/js/angular.js:1909:20)    at bootstrap (http://192.168.0.175:8020/AngularJS/js/angular.js:1930:12)http://errors.angularjs.org/1.6.3/$injector/modulerr?p0=dayApp&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'dayApp'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.6.3%2F%24injector%2Fnomod%3Fp0%3DdayApp%0A%20%20%20%20at%20http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A66%3A12%0A%20%20%20%20at%20http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A2257%3A17%0A%20%20%20%20at%20ensure%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A2178%3A38)%0A%20%20%20%20at%20module%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A2255%3A14)%0A%20%20%20%20at%20http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A4896%3A22%0A%20%20%20%20at%20forEach%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A402%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A4880%3A5)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A4802%3A19)%0A%20%20%20%20at%20doBootstrap%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A1909%3A20)%0A%20%20%20%20at%20bootstrap%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A1930%3A12)    at http://192.168.0.175:8020/AngularJS/js/angular.js:66:12    at http://192.168.0.175:8020/AngularJS/js/angular.js:2257:17    at ensure (http://192.168.0.175:8020/AngularJS/js/angular.js:2178:38)    at module (http://192.168.0.175:8020/AngularJS/js/angular.js:2255:14)    at http://192.168.0.175:8020/AngularJS/js/angular.js:4896:22    at forEach (http://192.168.0.175:8020/AngularJS/js/angular.js:402:20)    at loadModules (http://192.168.0.175:8020/AngularJS/js/angular.js:4880:5)    at createInjector (http://192.168.0.175:8020/AngularJS/js/angular.js:4802:19)    at doBootstrap (http://192.168.0.175:8020/AngularJS/js/angular.js:1909:20)    at bootstrap (http://192.168.0.175:8020/AngularJS/js/angular.js:1930:12)http://errors.angularjs.org/1.6.3/$injector/modulerr?p0=dayApp&p1=Error%3A%20%5B%24injector%3Anomod%5D%20Module%20'dayApp'%20is%20not%20available!%20You%20either%20misspelled%20the%20module%20name%20or%20forgot%20to%20load%20it.%20If%20registering%20a%20module%20ensure%20that%20you%20specify%20the%20dependencies%20as%20the%20second%20argument.%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.6.3%2F%24injector%2Fnomod%3Fp0%3DdayApp%0A%20%20%20%20at%20http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A66%3A12%0A%20%20%20%20at%20http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A2257%3A17%0A%20%20%20%20at%20ensure%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A2178%3A38)%0A%20%20%20%20at%20module%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A2255%3A14)%0A%20%20%20%20at%20http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A4896%3A22%0A%20%20%20%20at%20forEach%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A402%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A4880%3A5)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A4802%3A19)%0A%20%20%20%20at%20doBootstrap%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A1909%3A20)%0A%20%20%20%20at%20bootstrap%20(http%3A%2F%2F192.168.0.175%3A8020%2FAngularJS%2Fjs%2Fangular.js%3A1930%3A12)    at http://192.168.0.175:8020/AngularJS/js/angular.js:66:12    at http://192.168.0.175:8020/AngularJS/js/angular.js:4920:15    at forEach (http://192.168.0.175:8020/AngularJS/js/angular.js:402:20)    at loadModules (http://192.168.0.175:8020/AngularJS/js/angular.js:4880:5)    at createInjector (http://192.168.0.175:8020/AngularJS/js/angular.js:4802:19)    at doBootstrap (http://192.168.0.175:8020/AngularJS/js/angular.js:1909:20)    at bootstrap (http://192.168.0.175:8020/AngularJS/js/angular.js:1930:12)    at angularInit (http://192.168.0.175:8020/AngularJS/js/angular.js:1815:5)    at http://192.168.0.175:8020/AngularJS/js/angular.js:33340:5    at HTMLDocument.trigger (http://192.168.0.175:8020/AngularJS/js/angular.js:3435:5):8020/favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)

2、错误原因

<!DOCTYPE html><html ng-app="dayApp"><head><meta charset="UTF-8"><title></title><link rel="stylesheet" href="../css/bootstrap.css" /><link rel="stylesheet" href="../css/bootstrap-theme.css" /><script type="text/javascript" src="../js/angular.js" ></script></head><body><div class="panel"><div class="page-header"><h3>AngularJS</h3></div><h1 ng-controller="dayCtl">今天是:{{day || "(未知)"}</h1><h1 ng-controller="tomCtl">明天是:{{day || "(未知)"}}</h1></div></body></html>

原因:

       (1)缺少右大括号“}”

       (2)缺少AngularJS模块和控制器结合控制


3、解决办法

<!DOCTYPE html><html ng-app="dayApp"><head><meta charset="UTF-8"><title></title><link rel="stylesheet" href="../css/bootstrap.css" /><link rel="stylesheet" href="../css/bootstrap-theme.css" /><script type="text/javascript" src="../js/angular.js" ></script><script>var app = angular.module("dayApp",[]);app.controller("dayCtl",function($scope){});app.controller("tomCtl",function($scope){});</script></head><body><div class="panel"><div class="page-header"><h3>AngularJS</h3></div><h1 ng-controller="dayCtl">今天是:{{day || "(未知)"}}</h1><h1 ng-controller="tomCtl">明天是:{{day || "(未知)"}}</h1></div></body></html>

0 0
原创粉丝点击