Open jeandat opened 6 years ago
It wasn't intended to be loaded as a feature any more than HttpClient
is intended to be loaded anywhere other than at the root.
But it should work IF AND ONLY IF you re-import HttpClient into the lazy feature module at the SAME TIME and SAME PLACE that you import this in-mem module.
Try it.
Correct me if i'm wrong, but if I'm using http interceptors, it would be bad for me to import again HttpClientModule in my lazy feature module? My interceptor would not be invoked anymore, right?
@jdat82, you are not wrong. Currently working through this problem now. Any suggestions/what path did you go with?
The only path I can see is to import all my in-mem services into my core module, which would not be ideal.
Yes, that's what I did too. That's not ideal but there is no better solution for now.
I have the same issue. I need the InMemoryService
just inside a few feature modules. I don't importing HttpClientModule
again so I did. Still doesn't work even if I have it imported again. I did check the order and it is good. The InMemoryService
does not get instantiated in my case - the createDB()
method never gets called. Any clue what might be causing this?
I created a small repo to reproduce the situation. According to documentation, it is possible to use in-memory-web-api in a lazy loaded module. I might be misunderstanding something.
Also, I'm wondering, is it possible to declare several mock services in several modules or do you need to declare everything inside one service.
Thanks.
lazy.zip