gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 20:18:02 31 4
gpt4 key购买 nike

我们已经使用 Angular v6.0.0-beta.3 很长时间了,但最近我们尝试升级到版本 6.1.3。

我无法使用 Angular 原理图进行升级,因为它们似乎不支持外部注册表(我们使用 Artifactory),所以我不得不手动升级它,所以很可能我搞砸了一些东西。

目前升级后我得到了这个堆栈跟踪:

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 注入(inject) AuthService。如果我将 AuthService 放入 LoginComponent 的 provide 数组属性中,那么它就会停止提示该错误,并为另一个组件提供相同的错误。我尝试用新的 providedIn: 'root' 配置替换所有 Injectable,但它仍然不起作用。我尝试清理 npm 缓存并删除 node_modules ,但仍然存在同样的问题。我对自己做错的事感到迷失。

在 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)

任何帮助将不胜感激。

编辑:LoginComponent 构造函数

constructor(
private authService: AuthService) {
}

AuthService类声明

    @Injectable()
export class AuthService {

我的所有提供程序都在 AppModule 中提供。

最佳答案

在 LoginComponent 中围绕 AuthService 实例化添加 @Inject 装饰器

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

这有助于编译器知道 AuthService 将在稍后注入(inject)。

关于 Angular 6 : Can't resolve all parameters for Component: (?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51975073/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com