1

I'd like to inject constants into the app.config() step in angularjs. But is does not work. How could I achieve this?

var app = angular.module(..);

app.constant('MY_CONST', {
    //...
};

app.config(['MY_CONST', function($routeProvider, MY_CONST) {
    //...
}

Result: Error [$injector:modulerr]

1 Answer 1

1

You forgot to inject $routeProvider in config.

app.constant('MY_CONST', {
    //...
}); // Missing ) here

app.config(['$routeProvider', 'MY_CONST', function($routeProvider, MY_CONST) {
//          ^^^^^^^^^^^^^^^^
    //...
}); // Missing ) here
Sign up to request clarification or add additional context in comments.

Comments

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.