mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 06:51:19 +08:00
37 lines
664 B
Plaintext
37 lines
664 B
Plaintext
```ts
|
|
// TodoItem.stories.ts
|
|
|
|
import { moduleMetadata, Story, Meta } from '@storybook/angular';
|
|
|
|
import fetch from 'node-fetch';
|
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
import TodoItem from './TodoItem';
|
|
|
|
export default {
|
|
component: TodoItem,
|
|
decorators: [
|
|
moduleMetadata({
|
|
declarations: [TodoItem],
|
|
imports: [CommonModule],
|
|
}),
|
|
],
|
|
title: 'Examples/Loader',
|
|
} as Meta;
|
|
|
|
export const Primary = (args, { loaded: { todo } }) => {
|
|
return {
|
|
props: {
|
|
args,
|
|
todo,
|
|
},
|
|
};
|
|
};
|
|
|
|
Primary.loaders = [
|
|
async () => ({
|
|
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
|
|
}),
|
|
];
|
|
``` |