1

I get this error:

Uncaught Error: [$injector:modulerr]

But I do not remember what I did wrong, so how can I find what causes this error?

JS:

angular.module('app', ['ngMaterial', 'angular-loading-bar', 'ngAnimate'])
.config(function($mdIconProvider) {
    $mdIconProvider
        .defaultFontSet( 'fontawesome' )
        .iconSet("call", '/images/icons/sets/communication-icons.svg', 24)
        .iconSet("social", '/images/icons/sets/social-icons.svg', 24);
})
.controller('AppCtrl', function ($scope, $timeout, $mdSidenav, $mdUtil, $log) {
    $scope.toggleLeft = buildToggler('left');
    $scope.toggleRight = buildToggler('right');
    /**
     * Build handler to open/close a SideNav; when animation finishes
     * report completion in console
     **/
    function buildToggler(navID) {
        var debounceFn =  $mdUtil.debounce(function(){
            $mdSidenav(navID)
                .toggle()
                .then(function () {
                    $log.debug("toggle " + navID + " is done");
                });
        },200);
        return debounceFn;
    }
    $scope.closeLeft = function () {
        $mdSidenav('left').close()
        .then(function () {
            $log.debug("close LEFT is done");
        });
    };
    $scope.closeRight = function () {
        $mdSidenav('right').close()
        .then(function () {
            $log.debug("close RIGHT is done");
        });
    };

    var originatorEv;
    this.openMenu = function($mdOpenMenu, ev) {
        originatorEv = ev;
        $mdOpenMenu(ev);
    };
});


function DialogController($scope, $mdDialog) {
    $scope.hide = function() {
        $mdDialog.hide();
    };
    $scope.cancel = function() {
            $mdDialog.cancel();
    };
    $scope.answer = function(answer) {
        $mdDialog.hide(answer);
    };
}

ps. I do not use ngRoute in my App if that is the cause of the error.

Mustapha Aoussar
  • 5,833
  • 15
  • 62
  • 107

1 Answers1

3

You should probably use an unminified version of Angular to get better error handling.

Also I always recommend using strict dependency injection like so:

.config(['$mdIconProvider', function($mdIconProvider) {
....
]);
Mo Binni
  • 265
  • 1
  • 12
  • methinks, you find solution if user minify his code :-) – Grundy Oct 15 '15 at 09:28
  • Sorry how do you mean? I meant because in the error message it says angular.min.js he should go for angular.js unminified in a dev environment. – Mo Binni Oct 15 '15 at 09:31
  • @MoBinni Thank you so much! I will try to use unminified version of Angular. – Mustapha Aoussar Oct 15 '15 at 09:32
  • 1
    My pleasure :) happy to help, hit me up if you have any Angular-specific questions. – Mo Binni Oct 15 '15 at 09:33
  • i mean, if OP minify own code, after minification angular can't inject service, and raise error, ofcourse if not injected manually – Grundy Oct 15 '15 at 09:33
  • Yeah you're right, that would work, but don't you think it's easier in development to work off unminified code. – Mo Binni Oct 15 '15 at 09:34
  • @MoBinni, if use approach OP, whithout annotation, so in dev code all would work, and in prod - error :-) Because problem not in angular version, but in OP code – Grundy Oct 15 '15 at 09:36
  • I didnt specify it was the angular version tho just the type ^^ but ur right it would work that way, I just find it more useful to run unminified in dev – Mo Binni Oct 15 '15 at 10:17