得到了在Storybook中包含一个独立管道的任务。我的管道简单如:从“@angular/core”导入{管道,管道变换};
@Pipe({
name: 'shortpipe',
standalone: true,
})
export class ShortPipe implements PipeTransform {
transform(value: any): any {
return 'hello';
}
}
即使我的故事书故事也没有那么复杂:
const meta: Meta<any> = {
title: 'Title of my fantastic story',
render: () => ({
template: `<p>{{'22222' | shortpipe}}</p>`,
}),
};
export default meta;
type Story = StoryObj<any>;
export const Default: Story = {
render: (args) => ({
moduleMetadata: [
{
imports: [ShortPipe],
},
],
template: `<p>{{'22222' | shortpipe}}</p>`,
}),
};
然而,我得到了错误:NG0302: The pipe 'shortpipe' could not be found in the 'StorybookWrapperComponent' component. Verify that it is declared or imported in this module. Find more at https://angular.io/errors/NG0302
Angular :15.0.2
@故事书/棱角:6.5.15
1条答案
按热度按时间x8diyxa71#
已经找到了答案,问题只是把moduleMetadata导入放到了错误的位置。把它移到装饰器数组中修复了它: