Error when trying to inject a service into an angular component “EXCEPTION: Can't resolve all parameters for component”, why?

前端 未结 30 1438
无人共我
无人共我 2020-11-22 17:18

I\'ve built a basic app in Angular, but I have encountered a strange issue where I cannot inject a service into one of my components. It injects fine into any of the three o

30条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 17:36

    In addition to the missing @Injectable() decorator

    Missing @Injectable() decorator in abstract class produced the Can't resolve all parameters for service: (?) The decorator needs be present in MyService as well as in the derived class BaseService

    //abstract class
    @Injectable()
    abstract class BaseService { ... }
    
    //MyService    
    @Injectable()
    export class MyService extends BaseService {
    .....
    }
    

提交回复
热议问题