简体   繁体   English

Angular 6:无法解析Component的所有参数(?)

[英]Angular 6: Can't resolve all parameters for Component: (?)

We've been on Angular v6.0.0-beta.3 for a long time, but recently we've tried upgrading to version 6.1.3. 我们已经使用Angular v6.0.0-beta.3很长时间了,但是最近我们尝试升级到6.1.3版。

I've been unable to upgrade using angular schematics as they don't seem to support external registries (we use Artifactory) so I've had to upgrade it manually so it's very possible I've messed something up. 我一直无法使用角度示意图进行升级,因为它们似乎不支持外部注册表(我们使用Artifactory),因此我不得不手动对其进行升级,因此很可能我搞砸了。

Currently after upgrading I am getting this stacktrace: 目前,升级后,我得到此堆栈跟踪:

Uncaught Error: Can't resolve all parameters for LoginComponent: (?).
at syntaxError (compiler.js:1016)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (compiler.js:10917)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (compiler.js:10810)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNonNormalizedDirectiveMetadata (compiler.js:10429)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getEntryComponentMetadata (compiler.js:11013)
at compiler.js:11004
at Array.forEach (<anonymous>)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getEntryComponentsFromProvider (compiler.js:11003)
at compiler.js:10976
at Array.forEach (<anonymous>)

LoginComponent injects the AuthService. LoginComponent注入AuthService。 If I put AuthService in the provide array property of the LoginComponent then it stops complaining about that error and gives me the same error for another component. 如果我将AuthService放在LoginComponent的provide数组属性中,则它将停止抱怨该错误,并为另一个组件提供相同的错误。 I've tried replacing ALL Injectable's with the new providedIn: 'root' configuration but it still doesn't work. 我尝试用新的providedIn: 'root'配置替换ALL Injectable,但是它仍然无法正常工作。 I've tried cleaning npm cache and removing node_modules and still the same problem. 我试过清理npm缓存并删除node_modules,仍然是同样的问题。 I'm lost on what I've done wrong. 我因做错了事而迷失了方向。

Running in AOT actually correctly launches the app, but then I get these stack traces when doing things with some components (I think material): 在AOT中运行实际上可以正确启动应用程序,但是当我使用某些组件(我认为是材料)进行处理时,我得到了这些堆栈跟踪信息:

ERROR TypeError: a[getSymbolIterator(...)] is not a function
at areIterablesEqual (core.js:5492)
at devModeEqual (core.js:5421)
at checkBindingNoChanges (core.js:7689)
at checkNoChangesNodeInline (core.js:10552)
at checkNoChangesNode (core.js:10541)
at debugCheckNoChangesNode (core.js:11144)
at debugCheckDirectivesFn (core.js:11072)
at Object.updateDirectives (login.component.html:37)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:11061)
at checkNoChangesView (core.js:10440)

Any help would be greatly appreciated. 任何帮助将不胜感激。

Edit: LoginComponent constructor 编辑:LoginComponent构造函数

constructor(
    private authService: AuthService) {
  }

AuthService class declaration AuthService类声明

    @Injectable()
export class AuthService {

All my providers are provided in the AppModule. 我的所有提供程序都在AppModule中提供。

Add @Inject decorator around AuthService instantiation in the LoginComponent 在LoginComponent中的AuthService实例周围添加@Inject装饰器

constructor(
  @Inject(AuthService) private authService: AuthService) {
}

This helps compiler know that AuthService will be injected later. 这有助于编译器知道AuthService将在以后注入。

AuthServiceproviders的阵列AppModule

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM