简体   繁体   English

无法读取未定义的属性“模块”

[英]Cannot read property 'module' of undefined

I have a basic understanding of Django and JS and recently I started learning Angular.js . 我对DjangoJS有基本的了解,最近我开始学习Angular.js I wrote code for showing hardcoded json using Angular and failed. 我编写了使用Angular显示硬编码json代码并失败了。 I got the following error: 我收到以下错误:

Uncaught TypeError: Cannot read property 'module' of undefined at line 10 of django-angular.js

I went through the file and saw this line: 我浏览了文件并看到了这一行:

var djng_forms_module = angular.module('ng.django.forms', []);

I don't know what the error means by undefined. 我不知道undefined意味着什么错误。 I went through some of the links having similar problems but with no success. 我经历了一些有类似问题但没有成功的链接。

Have you forgotten to load AngularJS before your script? 您是否忘记在脚本之前加载AngularJS? The error means that the object angular hasn't been seen by Javascript yet and therefore module cannot be called on it. 该错误意味着Javascript尚未看到对象angular ,因此无法在其上调用module

(that's actually a simplification but it should illustrate what's going on) (这实际上是一种简化,但它应该说明发生了什么)

order matters here 订购事项在这里

<script src="javascripts/lib/angular.min.js" type="text/javascript"></script>
<script src="javascripts/lib/angular-route.min.js" type="text/javascript"></script>
<script type="text/javascript" src="angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-cookies.js"></script> 
<script type="text/javascript" src="angular-route.js"></script>

you have to put angular.min.js before angular-route.js and angular-cookies.js 你必须在angular-route.js和angular-cookies.js之前加上angular.min.js

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

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