Storybook: Unable to configure story for module with RouterLink

Created on 14 Jan 2020  路  4Comments  路  Source: storybookjs/storybook

Describe the bug
Cannot configure story for module where routerLink is used due to error

ERROR NullInjectorError: StaticInjectorError(DynamicModule)[RouterLinkActive -> Router]

To Reproduce
Steps to reproduce the behavior:
https://github.com/Adam-Michalski/theme-demo-app
Run app and you can test that there is no possible solution to add RouterModule to work with story.
It cannot be configured with RouterTestingModule, RouterModule, RouterModule.forRoot with iframe.html path. There is always the sam error about missing provider.

Expected behavior
To run application and story with routerLink

Additional context
Latest version of storybook 5.3.3 and angular ~8.2.14

I was working with different configuration 5.2.8 and this issue does not appear.

angular inactive question / support

All 4 comments

I don't understand why navbar is a module? But anyway, it can't work in that way that you're importing router module inside navbarModule which is importing to story.
I would propose you to delete navbar.module and keep it just as a component, but still - if you need as a module then in your story you should just import RouterTestingModule and declare component:

moduleMetadata({
      declarations: [NavbarComponent],
      imports: [RouterTestingModule],
}),

ERROR NullInjectorError: "StaticInjectorError(DynamicModule)[RouterOutlet -> ChildrenOutletContexts]:
StaticInjectorError(Platform: core)[RouterOutlet -> ChildrenOutletContexts]:
NullInjectorError: No provider for ChildrenOutletContexts!"

how can i solve it.....

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Same for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moimikey picture moimikey  路  67Comments

ilias-t picture ilias-t  路  73Comments

Gongreg picture Gongreg  路  58Comments

dependencies[bot] picture dependencies[bot]  路  142Comments

aericson picture aericson  路  97Comments