【发布时间】:2016-04-25 15:40:12
【问题描述】:
我正在通过 Youtube 上的视频教程从 Google 学习新框架 Angular2:https://www.youtube.com/watch?v=SEM6-TkuOgo
我在开始学习服务时遇到了不同类型的错误,例如:
异常:无法解析“ContactListComponent”(?) 的所有参数。确保所有参数都使用 Inject 进行修饰或具有有效的类型注释,并且 'ContactListComponent' 使用 Injectable 进行修饰。
异常:错误:未捕获(承诺中):无法解析“ContactListComponent”(?)的所有参数。确保所有参数都使用 Inject 进行修饰或具有有效的类型注释,并且 'ContactListComponent' 使用 Injectable 进行修饰。
angular2-polyfills.js:469 未处理的承诺拒绝:无法解析“ContactListComponent”的所有参数(?)。确保所有参数都用 Inject 修饰或具有有效的类型注释,并且“ContactListComponent”用 Injectable 修饰。 ;区域:角度;任务:Promise.then ;价值:
NoAnnotationError {消息:“无法解析 'ContactListComp...ntactListComponent' 的所有参数被 Injectable 修饰。”,堆栈:“错误:无法解析 'ContactL...node_modules/angular2/bundles/angular2.js:477 的所有参数: 94)"} 信息 : “无法解析 'ContactListComponent'(?)的所有参数。确保所有参数都用 Inject 修饰或具有有效的类型注释,并且 'ContactListComponent' 用 Injectable 修饰。” 堆 : “错误:无法解析'ContactListComponent'(?)的所有参数。确保所有参数都用Inject修饰或具有有效的类型注释并且'ContactListComponent'被修饰/
angular2-polyfills.js:471 错误:未捕获(在承诺中):无法解析“ContactListComponent”(?)的所有参数。确保所有参数都用 Inject 修饰或具有有效的类型注释,并且'ContactListComponent' 用 Injectable 修饰。(...)
angular2-polyfills.js:469 未处理的承诺拒绝:无法解析“ContactListComponent”的所有参数(?)。确保所有参数都用 Inject 修饰或具有有效的类型注释,并且“ContactListComponent”用 Injectable 修饰。 ;区:;任务:Promise.then ;值:NoAnnotationError {消息:“无法解析 'ContactListComp...ntactListComponent' 的所有参数被 Injectable 修饰。”,堆栈:“错误:无法解析 'ContactL...node_modules/angular2/bundles/angular2.js:477:94 的所有参数)"}
angular2-polyfills.js:471 错误:未捕获(在承诺中):无法解析“ContactListComponent”(?)的所有参数。确保所有参数都用 Inject 修饰或具有有效的类型注释,并且'ContactListComponent' 用 Injectable 修饰。(...)
我不明白控制台的真正含义我试图注释代码的某些部分以测试我的代码何时编译。
如果觉得问题可能出在contact-list.component.ts中的这部分:
constructor(private _contactService: ContactService) {}
这个也在contact.service.ts中:
return Promise.resolve(CONTACTS);
我截取了项目中不同的 TypeScript 文件:http://imgur.com/a/mqb5P
如果有人有一些调试此代码的线索,我会全力以赴! :)
PS:如果有帮助,我可以从屏幕截图中复制/粘贴代码。
【问题讨论】: