Question

I am trying to experiment with examples and tutorials at http://docs.angularjs.org/guide/expression and the examples are not working in plunker and jsfiddle. I am getting this error in the console

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.0rc1/$injector/modulerr?p0=App&p1=Error%3A%…eapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.0rc1%2Fangular.min.js%3A27%3A198) 

Is this a known error?

Was it helpful?

Solution

JSFiddle in particular has always been difficult to get working with AngularJS. The HTML section isn't meant to take an entire HTML document. Instead, you need to configure the workspace to work with Angular following these steps:

  1. Under external resources, add the Angular script (remember to click the + icon)
  2. Under Fiddle Options change the body tag to include ng-app like so: <body ng-app>

That should get you started. If you don't mind using an older version of Angular (1.1.1), you can select it from the "Frameworks & Extensions" drop down and change the 2nd drop down from onLoad to No wrap - in <body>.

See here for a working example from the docs: http://jsfiddle.net/jPtb3/

And here for the optional approach using 1.1.1: http://jsfiddle.net/5nA2H/

Update

There's some misinformation in the comments.. The docs ARE actually creating angular.module for you, but they're passing in an empty dependency. So you can either remove ="App" (not best), or you fix the angular.module declaration by removing the empty dependency (best) like so:

angular.module('App', []);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top