我已经设置了要在Storybook中渲染的ag-grid。但是,当Storybook出现时,不会显示任何内容,并且Chrome控制台中会显示以下错误:
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)
我怀疑这是因为在Storybook模块中未正确设置ag-grid。这是我设置的方式-使用Strorybook装饰器:
import { AgGridNg2 } from 'ag-grid-angular';
...
storiesOf('Order List', module)
.addDecorator(
moduleMetadata({
declarations: [AgGridNg2]
})
)
.add('list with orders', () => ({
component: OrderListComponent,
props: {
orders: orders
}
}));
答案 0 :(得分:0)
已解决。我必须将AgGridModule
导入故事书:
.addDecorator(
moduleMetadata({
imports: [AgGridModule.withComponents([])]
})
)