1、错误
AppComponent.html:2 ERROR Error: StaticInjectorError(AppModule)[HeroesComponent -> HeroService]:
StaticInjectorError(Platform: core)[HeroesComponent -> HeroService]:
NullInjectorError: No provider for HeroService!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:951)
at resolveToken (core.js:1195)
at tryResolveToken (core.js:1140)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1035)
at resolveToken (core.js:1195)
at tryResolveToken (core.js:1140)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1035)
at resolveNgModuleDep (core.js:8071)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:8759)
at resolveDep (core.js:9124)
2、可能原因是我服务中内容删除的原因,小括号中的内容

在学习Angular过程中遇到AppComponent.html中的StaticInjectorError,错误源于服务组件内容删除。解决方案是在app/app.module.ts中正确注入相关服务。
1402

被折叠的 条评论
为什么被折叠?



