在尝试初始化我的应用程序时,我正在尝试将模块初始化为run()方法,但是它不会编译。
错误是:
Uncaught Error: [$injector:unpr] http://errors.angularjs.org/1.3.5/$injector/unpr?p0=%24routeProvider%20%3C-%20%24route
Error: error:unpr
Unknown Provider
Unknown provider: $routeProvider <- $route
这是app.js中的代码:
(function () {
'use strict';
angular.module('rage', [
'ui.router',
'ui.bootstrap',
'ui.dashboard',
'kendo.directives',
'jqwidgets'
]).run(['$route', '$rootScope', init]);
function init($route, $rootScope){
var i = 1;
}
})();
但是没有依赖关系,它运行良好:
(function () {
'use strict';
angular.module('rage', [
'ui.router',
'ui.bootstrap',
'ui.dashboard',
'kendo.directives',
'jqwidgets' // Kendo UI and jQWidgets libs (loaded in index.html)
]).run(init);
function init(){
var i = 1;
}
})();
答案 0 :(得分:2)
$routeProvider
不属于ui.router
模块。并且ui.router
也不使用ngRoute
,因此您无法访问运行块内的$route
服务,因为它不存在。如果您需要使用它,请尝试添加ngRoute
(但您已经有ui.router
,所以我不确定。)
angular.module('rage', [
'ngRoute' //<-- Here
'ui.router',
'ui.bootstrap',
'ui.dashboard',
'kendo.directives',
'jqwidgets'
]
或者只是从依赖项列表中删除$route
。