angular2项目报错:
core.es5.js:1084 ERROR Error: Uncaught (in promise): Error: No provider for UserService!
解决方法:
在app.module.ts文件中,把服务service加入到注入器providers中,如下所示:
const APP_PROVIDERS = [
AppState,
GlobalState,
AuthService,
UserService,
];
providers: [ // 将服务和提供者暴露为角度依赖性注入
APP_PROVIDERS
]
本文地址:http://www.yayihouse.com/yayishuwu/chapter/1226