Solved

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

Posted on 2015-01-13
3
2,098 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP get fieds value 2 22
Adding 1 the value of input "text" every 3 seconds 5 33
Link Anchor Not working 9 49
Glitching Slide Show 19 27
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

733 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