Solved

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

Posted on 2015-01-13
3
1,674 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
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now