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]
You forgot to inject $routeProvider
in config.
app.constant('MY_CONST', {
//...
}); // Missing ) here
app.config(['$routeProvider', 'MY_CONST', function($routeProvider, MY_CONST) {
// ^^^^^^^^^^^^^^^^
//...
}); // Missing ) here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.