Storybook: [Angular] how to change props dynamically?

Created on 12 May 2018  路  4Comments  路  Source: storybookjs/storybook

Bug or support request summary

Hi guys! First of all, thank you for this great library.
My question is how can i change props in angular component story dynamically?

Steps to reproduce

Story for example:

let enabled = true;

storiesOf('MySuperDirective', module)
  .addDecorator(
    moduleMetadata({
      declarations: [MySuperDirective]
    })
  )
  .add('toggle  directive', () => {
    return {
      template: `
        <div [mySuperDirective]="enabled"></div>
        <button (click)="toggleEnabled()">toggle</button>
      `,
      props: {
        toggleEnabled: () => {
          enabled = !enabled;
        },
        isEnabled: () => enabled
      }
      //want to
      //enabled: true
    };
  })

I can't find an example in documentation
https://storybook.js.org/basics/guide-angular/
or https://release-3-4--storybooks-angular.netlify.com/
And for now i can do it only with closures as you can see.
(I want just to pass props { enabled: true} and then change it when story already running)

Please specify which version of Storybook and optionally any affected addons that you're running

  • @storybook/angular 3.4.2
  • angular 4.4.6

Affected platforms

Windows 10
Chrome 66

angular

Most helpful comment

Are there any plans to support updating props values? Knobs is good for updating values but not for handling event based updates.

All 4 comments

Can't the knobs addon help you with it?

thank you!

Hi @nickbullock. How did you solve this problem? I don't see too much documentation on this.

Are there any plans to support updating props values? Knobs is good for updating values but not for handling event based updates.

Was this page helpful?
0 / 5 - 0 ratings