In the component I have a method onExample
. I am trying to override the functionality of the onExample
method from the storybook. As you can see below, I have tried to add the method as argTypes
and inside args
. But it does not work. I still get the console output From component
. How can I override the method?
In the storybook:
import { provideAnimations } from '@angular/platform-browser/animations';
import { applicationConfig, Meta, moduleMetadata, StoryObj } from '@storybook/angular';
const meta: Meta<ExampleComponent> = {
title: 'Example',
component: ExampleComponent,
decorators: [
applicationConfig({
providers: [provideAnimations(), importProvidersFrom(ExampleModule)],
}),
moduleMetadata({ imports: [ExampleModule] }),
fullSizeDecorator(),
],
argTypes: {
onExample: (value: any) => {
console.log('from story ', value);
},
},
};
export default meta;
type Story = StoryObj<ExampleComponent>;
export const example: Story = {
args: {
onExample: (value: any) => {
console.log('from story 2', value);
},
},
};
In the component example.component.ts
onExample(value): void {
console.log("From component ", value)
}