Reputation: 3813
This is surely a noob question but I just can't seem to figure out what is wrong with this simple module initiation (JSFiddle):
var myApp = angular.module('myApp', []);
I get an error saying that "Module 'myApp' is not available!". Does anyone know why this does not work?
Upvotes: 3
Views: 4908
Reputation: 2366
It's because (in the fiddle at least) that the script is run on window.onload
, thus angular cannot find the module before it sees in the DOM that there should be a module named myApp
.
before it was (in the head):
window.onload = function() {
angular.module(...)
}
but it had to be:
angular.module(...)
ie. not waiting until the document was fully loaded, thus creating the module before angular sees that it should bootstrap the module myApp
.
Upvotes: 1