Olloi Olloi - 2 months ago 15
AngularJS Question

Uncought Error injector::modulerr

How can i get this Error: $injector:modulerr
Module Error
by calling

angular.module('App', []).config(function () { });
?

The whole project worked correctly without any calls to .config(), but
i recently tried to add ng-route and got into this error even after removing any dependencies the bare config() throws the exception.

Answer

Try this one -

 angular.module('PtsApp', ['ngAnimate', 'angular.filter', 'ui.bootstrap', 'nvd3', 'ngRoute']) 
        .config(['$routeProvider', function ($routeProvider)  /* You wrongly spelled `routeProvider` while injecting as dependency, thats why you getting this error! */
        { 
            $routeProvider. 
            when('/1', { //.. }). 
            when('/2', { //... }). 
            otherwise({ redirectTo: '/' }); 
        }
        ]);

//You wrongly spelled routeProvider while injecting thats why you getting this error! Hope this help you! :)

Comments