Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'module' of undefined

I have a basic understanding of Django and JS and recently I started learning Angular.js. I wrote code for showing hardcoded json using Angular and failed. 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. I went through some of the links having similar problems but with no success.

like image 910
Sumit Gera Avatar asked Dec 13 '14 19:12

Sumit Gera


1 Answers

Have you forgotten to load AngularJS before your script? The error means that the object angular hasn't been seen by Javascript yet and therefore module cannot be called on it.

(that's actually a simplification but it should illustrate what's going on)

like image 181
Gregor Petrin Avatar answered Sep 24 '22 19:09

Gregor Petrin