1

I'm getting the classic "Module 'ngLocale' error is not available" error when angular tries to load up my module. I can't for the life of me figure out what dependency I am missing. Here's my app.js:

(function() {
    var app, dependencies;

    dependencies = ["ngRoute"];

    app = angular.module('myapp', dependencies);

    app.run(['$location', '$rootScope'], function($location, $rootScope) {
        $rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
            $rootScope.title = current.$$route.title;
        });
    });

    app.config(['$routeProvider'], function($routeProvider) {
        $routeProvider.when('/', {
            templateUrl: 'Content/views/home.html',
            controller: 'homeController',
            title: 'Home'
        }).otherwise({
            redirectTo: '/'
        });
    });
}).call(this);

My javascript files are loaded correctly in order. What am I missing?

2
  • Angularjs $route is in a separate file do you have it loaded? Commented Aug 20, 2014 at 14:31
  • Yes, angular-route.js gets loaded after angular.js but before this file. Commented Aug 20, 2014 at 14:32

1 Answer 1

3

you have to include the function in the array:

app.run(['$location', '$rootScope', function($location, $rootScope) {
    $rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
        $rootScope.title = current.$$route.title;
    });
}]);

and:

app.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/', {
        templateUrl: 'Content/views/home.html',
        controller: 'homeController',
        title: 'Home'
    }).otherwise({
        redirectTo: '/'
    });
}]);
Sign up to request clarification or add additional context in comments.

1 Comment

D'oh - it's always the little things. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.