获取"错误:[$injector:unpr]未知提供商"错误
Getting "Error: [$injector:unpr] Unknown provider" error
我正在编写基于此实践的路由解析:https://github.com/johnpapa/angular-styleguide#style-y081
但是我得到了:
错误:[$injector:unpr] Unknown provider: toursServiceProvider <- toursService <- MainController
我的代码是这样的:route-config.js文件
.when('/', {
templateUrl: 'scripts/partials/home.partial.html',
controller: 'MainController',
controllerAs: 'vm',
resolve: {
toursService: function(genericData) {
return genericData.getTours;
},
addressService: function(genericData) {
return genericData.getAddress;
},
aboutService: function(genericData) {
return genericData.getAbout;
}
}
})
main.controller.js文件:
(function () {
'use strict';
angular
.module('excursion')
.controller('MainController', MainController);
MainController.$inject = ['toursService', 'addressService', 'aboutService'];
function MainController(toursService, addressService, aboutService) {
// vm is our capture variable
var vm = this;
vm.tour = toursService.getTours;
vm.address = addressService.getAddress;
vm.about = aboutService.getAbout;
}
})();
最后我得到了它的工作,我需要$timeout使承诺可用时,控制器加载,这里是更新的代码(只是不同的路由,但逻辑是相同的):
.when('/tours', {
templateUrl: 'scripts/partials/pages/tours.partial.html',
controller: 'TourController',
controllerAs: 'vm',
resolve: {
toursService: function(genericData, $timeout) {
return $timeout(function() {
return genericData.getTours;
}, 1000);
}
}
})
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- "未捕获的语法错误:意外的标记}"
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- 为什么我会出现此错误"未捕获引用错误:未定义标题;
- "未捕获的语法错误:意外的标记"角度JS
- 内联javascript与"<脚本>"字符串错误地关闭了脚本标记
- jquery validate 1.8.1”;jQuery"是未定义的错误IE8
- 语法错误:"意外的标记<"在Web控制台中
- Backbone.View渲染错误"TypeError:无效'instanceof'操作数e.
- jsTree jQuery:select_node错误:"无法读取属性'obj'“未定义”;
- Parse.com Cloud Code beforeSave()错误:"未捕获尝试用指向新的未保存对象的指针
- MongoDb聚合$match错误:"参数必须是聚合管道运算符“;
- JavaScript运行时错误:“$"未定义-ASP.NET WebForms(MasterPage)
- AngularJS:试图使用一个服务,得到错误"无法读取属性'那么'“未定义”;
- Javascript/HTML”;错误”:"请使用POST请求“;将下拉选择与case/switch语句一起使
- Knockout.js动态选择模板错误:"找不到ID为'的模板'&”;
- 能够创建一个以字符串为键的映射,但当引用该键时;意外的数字错误"
- ReactJS+NodeJS:什么是错误"传递--update binary以重新安装或--build fro
- JSLint错误“是什么;类型错误"意思是