Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module is not available, misspelled or forgot to load (but I didn't)

I am fairly new to angular and using it with JSON api files. TO test, I am trying to use the free github api (my names for functions are for a different json api that i will be working with later). I just wanted to see if my functions were working with console.log(), but i receive this error in the console.

Uncaught Error: [$injector:modulerr] Failed to instantiate module MesaViewer due to: Error: [$injector:nomod] Module 'MesaViewer' 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.

I have spelled MesaViewer the exact same in both, and dependencies are seen in the second line!

var app = angular.module("MesaViewer"); var MainController = function($scope, $location, $http, $routeParams) { 

What did I do wrong? Here is my plunk: http://plnkr.co/edit/sZPaFbzbOB6AmVCLL1vq

like image 630
Ian McCleary Avatar asked Jul 13 '15 22:07

Ian McCleary


2 Answers

It should be

var app = angular.module("MesaViewer", []); 

This is the syntax you need to define a module and you need the array to show it has no dependencies.

You use the

angular.module("MesaViewer"); 

syntax when you are referencing a module you've already defined.

like image 75
Matt Herbstritt Avatar answered Sep 21 '22 18:09

Matt Herbstritt


You are improperly declaring your main module, it requires a second dependencies array argument when creating a module, otherwise it is a reference to an existing module

Change:

var app = angular.module("MesaViewer"); 

To:

var app = angular.module("MesaViewer",[]); 

Working Version

like image 37
charlietfl Avatar answered Sep 17 '22 18:09

charlietfl