AngularJS 1.2 $injector:modulerr AngularJS 1.2 $injector:modulerr javascript javascript

AngularJS 1.2 $injector:modulerr


The problem was caused by missing inclusion of ngRoute module. Since version 1.1.6 it's a separate part:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>var app = angular.module('myapp', ['ngRoute']);


my error disappeared by adding this '()' at the end

(function(){    var home = angular.module('home',[]);    home.controller('QuestionsController',function(){        console.log("controller initialized");        this.addPoll = function(){            console.log("inside function");        };    });})();


One more thing to add to the list as this is the first result that comes up with a google search of 'Error: [$injector:modulerr] angular':

If you have a mismatch between your app name in your 'index'html' and in your main javascript app definition this can also generate this error.

For example if your HTML looks like this:

    </head>    <body ng-app="myWebSite">        <!-- My Web Site -->        <p>About my web site...</p>        etc ...

And your JavaScript looks like this (i.e has a typo on app name - myWebCite instead of myWebSite):

/** Main AngularJS Web Application */ var app = angular.module('myWebCite', [ 'ngRoute' ]); /** Configure the Routes */ app.config(['$routeProvider', function ($routeProvider) {   etc ...

then the 'Error:[$injector:modulerr] angular' error will be generated also.