Skip to content

Instantly share code, notes, and snippets.

@ali-kamalizade
Last active February 24, 2020 20:37
Show Gist options
  • Save ali-kamalizade/1676a4b29be28e967e651212eda8e02d to your computer and use it in GitHub Desktop.
Save ali-kamalizade/1676a4b29be28e967e651212eda8e02d to your computer and use it in GitHub Desktop.
Custom Angular Form Control in Storybook
// ...
storiesOf('Forms|JsonFormControlComponent', module)
.addDecorator(withKnobs) // optional: requires https://www.npmjs.com/package/@storybook/addon-knobs to be installed
.addDecorator(moduleMetadata({
imports: [FormsModule],
declarations: [JsonFormControlComponent] // the component we want to test
}))
.add('using an object', () => ({
component: JsonFormControlComponent, // if you want to have control over the template, you should use "template" instead
props: {
ngModel: {id: '123', email: 'test@example.org'}, // enable data binding
ngModelChange: action('ngModelChange'), // outputs the latest value
height: text('Set the height of the component', '600px') // optional knob: allow to set height of the component directly in Storybook
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment