?
Solved

Help with AngularJS - Error: [$injector:nomod] Module 'app' is not available!

Posted on 2015-01-13
3
Medium Priority
?
2,580 Views
Last Modified: 2015-02-03
Any idea why this error occurs?
Error: [$injector:nomod] Module 'app' is not available!


http://jsfiddle.net/JElster/me5Lcvsq/1/



<div ng-app="app" ng-controller="ctrl">
  {{catalog}}
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>




var app = angular.module('app', ['jsonService']);

angular.module('jsonService', ['ngResource'])
.factory('JsonService', function($resource) {
  return $resource('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93930/catalog.json');
});

app.controller('ctrl', function($scope, JsonService){
  JsonService.get(function(data){
    $scope.catalog = data;
  });
});
0
Comment
Question by:JElster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 2000 total points
ID: 40546549
I'm not sure if you can put the ng-app and the ng-controller in the same DOM element...
I would say that you can't.

Try something like:
<div ng-app="app">
<div ng-controller="ctrl">
  {{catalog}}
</div>
</div>

Open in new window

I don't know what's your reason to have it like you have but usually the ng-app goes in the broadest element possible... the <html> or the <body> for instance.
0
 
LVL 1

Author Comment

by:JElster
ID: 40546585
Still get
 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40546622
Where are you adding your javascript that contains the module?
It should be added after the angularjs javascript file reference.

Do you have any other javascript errors in the console?
Disn't you forget to add the reference to the javascript file that contains the code (happens very often)?
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question