0
votes

I have a library that I has one module and two components in it. One of the components needs to use a service (and has a config being passed in - which worked before I added the service to the constructor).

ERROR Error: Uncaught (in promise): Error: This constructor was not compatible with Dependency Injection.
Error: This constructor was not compatible with Dependency Injection.
    at Module.ɵɵinvalidFactory (core.js:13777)
    at NodeInjectorFactory.QrCodeService_Factory [as factory] (qr-code.service.ts:26)
    at getNodeInjectable (core.js:4029)
    at searchTokensOnInjector (core.js:3965)
    at getOrCreateInjectable (core.js:3887)
    at Module.ɵɵdirectiveInject (core.js:13753)
    at NodeInjectorFactory.QrCodeComponent_Factory [as factory] (qr-code.component.ts:21)
    at getNodeInjectable (core.js:4029)
    at instantiateRootComponent (core.js:7826)
    at createRootComponent (core.js:18375)
    at resolvePromise (zone-evergreen.js:798)
    at resolvePromise (zone-evergreen.js:750)
    at zone-evergreen.js:860
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:27425)
    at ZoneDelegate.invokeTask (zone-evergreen.js:398)
    at Zone.runTask (zone-evergreen.js:167)
    at drainMicroTaskQueue (zone-evergreen.js:569)

Am I missing something?

Service (QrCodeService) is decorated with:

@Injectable({
  providedIn: 'any'
})

Component (QrCodeComponent) is decorated with:

@Component({
  providers: [
    QrCodeService
  ]
})

And the component's constructor:

constructor(
  @Inject(QR_LIB_CONFIG) qrLibConfig,
  private qrCodeService: QrCodeService
)
please, provide QrCodeService.constructor the problem should be thereAndrei
@Andrei - Wow! That was it! I had an HttpClient param in the constructor but was not importing it into my module. Thank you!RadianceBox