简体   繁体   English

为什么我在 angular.min.js 中收到此错误

[英]Why am i getting this error in the angular.min.js

Hey after installing angular i made a simple routing script and for some reason the console is saying there is an error in the angular.min.js and i do not know why becuse i got it directly from the anularjs.org website.嘿,安装 angular 后,我制作了一个简单的路由脚本,出于某种原因,控制台说 angular.min.js 中存在错误,我不知道为什么,因为我直接从 anularjs.org 网站获得了它。 The console is showing this error.控制台显示此错误。

Uncaught Error: [$injector:modulerr]
http://errors.angularjs.org/1.5.9/$injector/modulerr?p0=englishHosts&p1=Err…
localhost%2Fvendor%2Fbuild%2FAngularJavascript%2Fangular.min.js%3A21%3A332)
    at angular.js:38
    at angular.js:4683
    at q (angular.js:325)
    at g (angular.js:4644)
    at eb (angular.js:4566)
    at c (angular.js:1803)
    at Ic (angular.js:1824)
    at ue (angular.js:1709)
    at angular.js:32379
    at HTMLDocument.b (angular.js:3251)

My index.html has我的 index.html 有

<!DOCTYPE html>
<html lang="en" ng-app="englishHosts">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="../vendor/libs/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="../vendor/libs/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script src="../vendor/build/AngularJavascript/angular.min.js"></script>
    <script src="../vendor/build/AngularJavascript/angular-route.min.js"></script>
    <script>
      var app = angular.module("englishHosts", ["ngRoute"]);
    </script>
  </head>
  <body>
    <div ng-view></div>
  </body>
</html>

This error still occurs without the app.js.如果没有 app.js,这个错误仍然会发生。 Any help would be helpful.任何帮助都会有所帮助。

There is a 'modulerr' error because you don't define the module englishHosts.存在“modulerr”错误,因为您没有定义模块 englishHosts。

Your app.js must contains something like this:您的 app.js 必须包含如下内容:

angular.module('englishHosts',[]);

And don't forget:并且不要忘记:

<script src="app.js"></script>

This appears in the http link : http://errors.angularjs.org/1.5.9/ $injector/modulerr?p0=englishHosts...这似乎在HTTP链接: http://errors.angularjs.org/1.5.9/ ?$喷油器/ modulerr P0 = englishHosts ...

(look at the p0 parameter in the url) (查看url中的p0参数)

If you follow this 'error link', you will have some details.如果您遵循此“错误链接”,您将获得一些详细信息。

I think the error you are seeing is because you are defining in the html我认为您看到的错误是因为您在 html 中定义

<html lang="en" ng-app="englishHosts">

and it cannot find the module called englishHosts它找不到名为englishHosts的模块

 // When this is commented out it will throw an error because it cannot find the module declared in the html ! // var app = angular.module("myApp",[]);
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myApp" > </div>

{
  "message": "Script error.",
  "filename": "",
  "lineno": 0,
  "colno": 0
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM