0

I have set up ag-grid to be rendered inside Storybook. However when Storybook comes up nothing displays and the following error is displayed in the Chrome console:

ERROR Error: StaticInjectorError(DynamicModule)[Ng2FrameworkFactory -> BaseComponentFactory]: 
StaticInjectorError(Platform: core)[Ng2FrameworkFactory -> BaseComponentFactory]: 
NullInjectorError: No provider for BaseComponentFactory!
    at NullInjector../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:1034)
    at resolveToken (core.js:1271)

I suspect this is because ag-grid is not set up correctly in the Storybook module. Here's how I have set it up - using the Strorybook decorator:

import { AgGridNg2 } from 'ag-grid-angular';
...

storiesOf('Order List', module)
    .addDecorator(
        moduleMetadata({
            declarations: [AgGridNg2]
        })
    )
    .add('list with orders', () => ({
        component: OrderListComponent,
        props: {
            orders: orders
        }
    }));

Any idea what I could be doing wrong? The full project is available on Github, specifically the Storybook story is here.

Naresh
  • 23,937
  • 33
  • 132
  • 204

1 Answers1

1

Solved. I had to import AgGridModule into storybook:

.addDecorator(
    moduleMetadata({
        imports: [AgGridModule.withComponents([])]
    })
)
Naresh
  • 23,937
  • 33
  • 132
  • 204