错误: [$injector:unpr] 未知提供程序 ->,因为 ui 路由器请求了错误的内容
Error: [$injector:unpr] Unknown provider -> because ui-router requests the wrong thing
我最近从ngRoute
切换到ui-router
,由于不应该存在的奇怪效果,我的近 90% 的代码不再工作。
这是我的一个控制器的构造函数:
constructor(
cameraApiService: ICameraApiService,
$log: ng.ILogService,
$stateParams: any) {
有了ngRoute
,ICameraApiService
(class CameraApiService
)可以毫无问题地注入。现在有了ui-router
,它无法解决ICameraApiService
。经过进一步调查,我发现 angular 不会试图解决CameraApiService
,而是cameraApiServiceProvider
:
Error: [$injector:unpr] Unknown provider: cameraApiServiceProvider <- cameraApiService
http://errors.angularjs.org/1.3.8/$injector/unpr?p0=cameraApiServiceProvider%20%3CameraApiService
这当然不存在。就DI而言,ngRoute
和ui-router
之间有区别吗?事情必须以不同的方式声明吗?
顺便说一句:我正在使用Typescript
和grunt-tsng
。所有依赖项/模块/服务都已注册。
请参阅转换后的.js文件,第 73 行:controller: App.Cameras.CameraListController
。 这里的控制器应该引用一个字符串名称,如controller: 'App.Cameras.CameraListController'
相关文章:
- ui网格日期单元格过滤器,过滤日期格式导致显示错误的日期
- 使用FB.ui的Facebook Feed对话给出API错误191
- jquery ui自动完成导致标头错误
- jQuery UI对话框错误,按钮导致HierarchyRequestError
- 在选项卡中使用时,Onsen UI拉钩会抛出错误
- Typescript Kendo UI网格列类型错误
- 使用Backbone在模型更改时渲染表单会导致表单UI错误
- 动态创建的 jQuery UI 对话框错误后 jQuery 2.2.0 升级
- 动手错误:在 jquery UI 中启动时,对话框是不可编辑的
- GAS 单击事件处理程序导致 UI Web 应用中出现“意外错误”
- 检测Kendo UI值绑定错误
- Kendo ui:未捕获类型错误:无法读取属性'至小写'的未定义
- 剑道 UI 网格绑定错误
- 如果存在 UI 错误,则禁止或提交记录 Netsuite Suitescript
- 角度 UI 类型提前不起作用 - 没有错误
- JQuery UI - 滑块更改幻灯片上的不透明度 - 错误
- 需要 / 角度 / 业力 / ui-router - 错误:无法从状态“”解析“登陆”
- 相对位置上的 UI.位置值错误
- “初始化前无法在工具提示上调用方法”错误,当我添加 jquery-ui 库时
- 选择类型错误 ui.item undefined Jquery 自动完成