Problem using ngx-graph as a lazy loaded module
cfrezier opened this issue · 3 comments
Describe the bug
When lazy loading ngxGRaphModule, i have an error:
ERROR NullInjectorError: R3InjectorError(AppModule)[LayoutService -> LayoutService -> LayoutService]:
NullInjectorError: No provider for LayoutService!
In order to try to solve the problem, i tried instanciating the service by myself, but
Module not found: Error: Package path ./lib/graph/layouts/layout.service is not exported from package
To Reproduce
Steps to reproduce the behavior:
- Make an example angular app
- Add a module
- Dynamically load that module using createNgModuleRef
- Try to use it
Expected behavior
ngx-graph working
ngx-graph version
^8.0.0
I have an angular module (let's say it's moduleA) that imports NgxModuleGraph (just like when using loadChildren).
I load that module using code that looks like:
import('./moduleA.module').then(module => {
const moduleRef = createNgModule(module['ModuleAName'], parentInjector);
const moduleAComponent = moduleRef.getComponent(); // resolved into a component from module A using ngx-graph
this.componentRef.createComponent(moduleAComponent);
})
It works when NgxGraphModule is imported in the main module, but not when it's only imported in moduleA.
At least if LayoutService was exported from package i could be able to provide it myself.
@cfrezier, In my scenario, I have a main component 'main', then there is a modalComponent which displays a modal, then there is the graphComponent and graphModule which is supposed to be rendered on the modal. When I directly use the NgxGraph module on the main component it works, but if I try to import the GraphModule and create graphComponent on the mainComponent it fails. Isn't it the same as what you just explained above?