Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem using ngx-graph as a lazy loaded module #473

Open
cfrezier opened this issue Nov 9, 2022 · 3 comments
Open

Problem using ngx-graph as a lazy loaded module #473

cfrezier opened this issue Nov 9, 2022 · 3 comments
Labels

Comments

@cfrezier
Copy link

cfrezier commented Nov 9, 2022

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:

  1. Make an example angular app
  2. Add a module
  3. Dynamically load that module using createNgModuleRef
  4. Try to use it

Expected behavior
ngx-graph working

ngx-graph version
^8.0.0

@cfrezier cfrezier added the bug label Nov 9, 2022
@shaswat94
Copy link

@cfrezier, How did you eagerly load the module?

@cfrezier
Copy link
Author

cfrezier commented Nov 17, 2022

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.

@shaswat94
Copy link

shaswat94 commented Nov 18, 2022

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants