Angular 2 - Can't resolve all parameters for component: (?)

前端 未结 4 643
死守一世寂寞
死守一世寂寞 2021-01-12 06:47

I started an Angular2 app and I have an issue since days !

Can\'t resolve all parameters for HomeComponent: (?).(…) 

But my issue is not a

4条回答
  •  深忆病人
    2021-01-12 07:23

    Import this

    import {Inject} from '@angular/core';
    

    And change your constructor to

    constructor(@Inject(AuthService) _authService: AuthService) 
    {
    
    }
    

    you should @Inject any service into constructor before using it.

    and your service should be injectable

    @Injectable()
    export class AuthService {
    
    }
    

提交回复
热议问题