Link to home
Start Free TrialLog in
Avatar of JElster
JElsterFlag for United States of America

asked on

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

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;
  });
});
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JElster

ASKER

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.
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)?