javascript - Failed to instantiate module myApp due to: Error: [$injector:nomod] http://errors.angularjs.org/1.2.26/$injector/nomod?p0=myApp -


I am trying to figure out angular and trying to write my first controller outside the web-based tutorial. I get an error in the title in JS console and can not understand what's going on. The link takes me to a page which refers to the need to include the NGURTTE, which I have done in accordance with the API. Of course I am missing something but I can not see what it is. Any help would be greatly appreciated, thanks!

index.html

app.js

  (function () {var app = angular.module ('myApp', ['ngRoute']); app.controller ('First Controller', function () {console.log ("First Controller Loaded");});})  

Your problem is that you forgot to apply iife which registers modules and controllers.

  (function () {var app = angular.module ('myApp', ['NgRoute']); app.controller ('first controller', function () {console.log ( "First Controller Loaded");})}}) (); // & lt; - Here in the link (in error) ngRoute talks as a signal for only one reason, because your module can not be available / installed when the angular  The ng-app  instruction tries to bootstrap it, but in your case it is also not present due to the failure to invite an anonymous function as IIFE. 


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -