0

I've been doing an Angular.js course, and now that I finished it, I wanted to give it a try and do some tests.

I used the basic html file for beginning:

<html ng-app="app.js">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="plugins/angular-min-1.4.3.js"></script>
  </head>
  <body>
  </body>
</html>

... which points to the simple angular app.js main module declaration:

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

Nothing strange here, no? I tried making a few directives and so, but nothing worked. Then, I found this error, which appears as soon as I only have the above code. I guess it's not adding well the plugin or I'm not declaring well the app variable.

12:32:44.547 Error: [$injector:modulerr] http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=app.js&p1=%5B%24injector%3Anomod%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.3%2F%24injector%2Fnomod%3Fp0%3Dapp.js%0AJ%2F%3C%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A6%3A416%0Ade%2F%3C%2F%3C%2F%3C%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A24%3A66%0Aa%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A23%3A109%0Ade%2F%3C%2F%3C%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A23%3A1%0Ag%2F%3C%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A37%3A381%0Am%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A7%3A320%0Ag%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A37%3A229%0Aeb%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A40%3A1%0AAc%2Fd%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A19%3A339%0AAc%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A20%3A151%0AZd%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A18%3A464%0A%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A289%3A428%0Aa%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A176%3A73%0AGf%2Fc%40http%3A%2F%2Flocalhost%2FAngularPruebas%2Fplugins%2Fangular-min-1.4.3.js%3A35%3A212%0A1 angular-min-1.4.3.js:6:415

Why does this happen?

1
  • The module is app not app.js. Also, try including the unminified version of Angular.js - it will give you more informative errors. Commented Jul 28, 2015 at 10:40

3 Answers 3

3

You have an error in html.
Your app is app, not app.js.

<html ng-app="app">
  <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script src="plugins/angular-min-1.4.3.js"></script>
  </head>
  <body></body>
</html>
Sign up to request clarification or add additional context in comments.

6 Comments

It still shows the same error. Nothing has changed at all.
Try to use the not-minified version of angular. The error message will get more clear.
BTW if you are getting the exactly same error, it means that you didn't change the html, as the error is mentioning app.js which is only in your html.
Ok, now it shows the whole error, but I still don't get why it doesn't instantiate the app module: Error: [$injector:modulerr] Failed to instantiate module app due to: [$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.
Have you included you app.js in your html?
|
1

Ok, I was being really silly not adding the app.js file. Now that I added it, ng-app="app" finds it properly.

Comments

0

On ng-app, you must say the name of the app, in this case it's "app" and not the file. I recommend you also not using ng-app on the HTML tag.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.