Search code examples
angularjsangularjs-routing

Angular, what dependency is missing


I'm learning angular.js and have all libraries linked from CDNs. When I try to use $locationProvider and $routeProvider I get this error:

Referee.config(["$locationProvider", "$routeProvider"], 
    function config($locationProvider, $routeProvider) {
        // ...
    }
);

angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.7/$injector/modulerr?p0=referee&p1=Error%3A…oogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.7%2Fangular.min.js%3A7%3A355)

From what I've seen an that error page I need to include ngRoute. So I linked route.min.js after my angular.min.js but it doesn't work and I still get the same error. What do I do wrong?

Here is jsbin


Solution

  • Seems like the array syntax is wrong; close the square bracket towards the end:

    Referee.config(["$locationProvider", "$routeProvider", 
        function config($locationProvider, $routeProvider) {
            // ...
        }
    ]);
    

    Why array notation? - Reason for using array notation when defining AngularJS Controller