0

I'm setting up my routing for a AngularJS v1.6 app, but I am running into a slight problem.

I am getting the following error, and I can't seem to figure out what is wrong. I hope you guys can shed some light into my error.

Uncaught Error: [$injector:modulerr] <http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=app&p1=Error%3A%20%…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.6.1%2Fangular.min.js%3A21%3A332>)
    at angular.js:38
    at angular.js:4759
    at q (angular.js:357)
    at g (angular.js:4720)
    at eb (angular.js:4642)
    at c (angular.js:1838)
    at Mc (angular.js:1859)
    at pe (angular.js:1744)
    at angular.js:32977
    at HTMLDocument.b (angular.js:3314)

Below is my code:

app.js;

(function () {
    "use strict";

    angular.module("app", [
        "ngRoute",
        "app.home",
        "app.products",
        "app.contact"
    ])

    .config(function ($routeProvider) {

        $routeProvider
            .when("/",
            {
                controller: "homeController",
                templateUrl: "app/components/home/home.html"
            })
            .when("/products",
            {
                controller: "productsController",
                templateUrl: "app/components/products/products.html"
            })
            .when("/contact",
            {
                controller: "contactController",
                templateUrl: "app/components/contact/contact.html"
            });
    });

})();

This is one of my controller (All 3 are the same) ...

(function() {
    "use strict";

    angular
        .module("app.home", [])
        .controller("homeController", homeController);

    function homeController() {
        this.helloWorld = "Hello World";
    }

});
Mistalis
  • 17,793
  • 13
  • 73
  • 97
ClarkySmiverz77
  • 203
  • 1
  • 4
  • 13
  • Please comment if you require more code or information. I imagine this is a simple error I am missing. Perhaps I will have better sight tomorrow with a fresh mind. – ClarkySmiverz77 Jan 08 '17 at 23:38

3 Answers3

1

Linking to the error message:

https://docs.angularjs.org/error/$injector/modulerr?p0=app&p1=undefined

Using ngRoute

In AngularJS 1.2.0 and later, ngRoute has been moved to its own module. If you are getting this error after upgrading to 1.2.x or later, be sure that you've installed ngRoute.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
0

Yes, this was a bug that I fixed within seconds of looking at my application with a fresh mind. Each of my controllers where missing the parenthesis at the end of the IIFY.

ClarkySmiverz77
  • 203
  • 1
  • 4
  • 13
0

I faced the same problem. Try including the ngRoute using angular-route.js in your view file

Barmao
  • 1
  • 2