Last active
February 24, 2020 20:37
-
-
Save ali-kamalizade/1676a4b29be28e967e651212eda8e02d to your computer and use it in GitHub Desktop.
Custom Angular Form Control in Storybook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
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