简体   繁体   English

角度,无法解析组件的所有参数

[英]Angular, can't resolve all parameters for Component

Erros msg: 错误信息:

Error: Can't resolve all parameters for LoginCompComponent: ([object Object], [object Object], [object Object], [object Object], ?).
Evaluating src/main.ts
Booting application

The Component looks like this: 该组件如下所示:

IMPORTS: 进口:

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import {MatSnackBar} from '@angular/material';
import { MatButtonModule, MatCheckboxModule } from '@angular/material';
import { OverlayReference } from './overlay-ref';

import { UsersService } from '../service/users.service';
import { OverlayService } from '../service/overlay.service';
import {TranslatePipe} from '../service/translate.pipe';
import {TranslationService} from '../service/translation.service';

CONSTRUCTOR: 建设者:

  constructor(
    private router: Router,
    private usersService: UsersService,
    //private overlay: OverlayService,
    public translationService: TranslationService,
    public snackBar: MatSnackBar,
) {}

Miracle is, if you comment the overlay:OverlayService it will work perfectly, and if I uncomment this line it will die, with the error message in the beginning. 奇迹是,如果你对此有何评论的overlay:OverlayService它会很好地工作,如果我取消这条线就会死亡,在一开始的错误消息。 Any thoughts? 有什么想法吗?

Here is a StackBlitz link, if you want to see the whole thing. 如果您想查看整个内容, 是一个StackBlitz链接。

You have a circular dependency between your TypeScript modules: OverlayService imports LoginComponent, and LoginComponent imports OverlayService. 您的TypeScript模块之间具有循环依赖关系:OverlayService导入LoginComponent,而LoginComponent导入OverlayService。

Refactor the code to avoid that. 重构代码以避免这种情况。

You import import { LoginCompComponent } from '../login-comp/login-comp.component' in OverlayService and you also import import { OverlayService } from '../service/overlay.service'; 您导入import { LoginCompComponent } from '../login-comp/login-comp.component'OverlayService,你也进口import { OverlayService } from '../service/overlay.service'; in LoginComponent . LoginComponent中

Very very bad practise :) Need to refactor this 非常非常糟糕的做法:)需要重构

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

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