oferh / ng2-completer

Angular 2 autocomplete component
http://oferh.github.io/ng2-completer/
MIT License
347 stars 172 forks source link

Custom Http service stops being injected to lazy loaded modules when ng2-completer is used #319

Open r0manchak opened 7 years ago

r0manchak commented 7 years ago

I have a special service responsible for handling all the http requests going from my application. It's injected in app.module file (root module) as following

{provide: ErrorHandler, useClass: CustomErrorHandler}

I also have a SharedModule which contains many other components and is imported by almost all of my modules.

The problem is when I import Ng2CompleterModule into my SharedModule my HttpClientService is no more used for request processing.

I suppose the problem has something in common with #296 but not sure about this. I don't use HttpClient.

Maybe this part of my package.json will be useful.

    "@angular/compiler": "^4.4.0-RC.0",
    "@angular/core": "^4.4.0-RC.0",
    "@angular/forms": "^4.4.0-RC.0",
    "@angular/http": "^4.4.0-RC.0",
    "ng2-completer": "^1.6.3",

PS. When I copy this line
{provide: ErrorHandler, useClass: CustomErrorHandler} to my shared.module file the service is injected twice.

That means multiple modules have multiple instances of the service.

Using useExisting doesn't help. It throws Provider not found exception.

oferh commented 7 years ago

try using version 2 it no longer uses HttpClient

r0manchak commented 7 years ago

Yes, thank you, that's what I did yesterday. The bug disappeared