1
我試圖建立一些常數通過供應商的角度配置,但由於某種原因,我不能看到,我不斷收到錯誤:AngularJS提供商不會注入angular.config
Unknown provider: myprovider
我在整個項目中都有大量的依賴注入,但我無法弄清楚爲什麼這個不起作用。
以下代碼的順序與我在config.js中的順序相同。
提供商
var trybConfig = angular.module('trybConfig', []);
trybConfig.provider('myprovider', function() {
this.Routes = {
EventList: {
Location: "/Event",
Template: "views/eventView.html",
Controller: "eventController"
}
}
this.$get = function() {
return this.Routes;
}
});
配置
trybConfig.config(function($routeProvider, myprovider) {
$routeProvider
.when('/Event', {
templateUrl: 'views/eventView.html',
controller: 'eventController'
})
.otherwise({
redirectTo: '/Event'
});
});