當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular.moduleMetadata函數代碼示例

本文整理匯總了TypeScript中@storybook/angular.moduleMetadata函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript moduleMetadata函數的具體用法?TypeScript moduleMetadata怎麽用?TypeScript moduleMetadata使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了moduleMetadata函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: storiesOf

storiesOf('Addon|Background', module)
  .addDecorator(
    withBackgrounds([
      { name: 'twitter', value: '#00aced', default: true },
      { name: 'facebook', value: '#3b5998' },
    ])
  )
  .add('background component', () => ({
    component: AppComponent,
    props: {},
  }));

storiesOf('Addon|Background', module)
  .addDecorator(
    moduleMetadata({
      declarations: [Button],
    })
  )
  .addDecorator(
    withBackgrounds([
      { name: 'twitter', value: '#00aced', default: true },
      { name: 'facebook', value: '#3b5998' },
    ])
  )
  .add('background template', () => ({
    template: `<storybook-button-component [text]="text" (onClick)="onClick($event)"></storybook-button-component>`,
    props: {
      text: 'Hello Button',
      onClick: (event: Event) => {
        console.log('some bindings work');
        console.log(event);
開發者ID:lyndontavares,項目名稱:storybook,代碼行數:31,代碼來源:addon-background.stories.ts

示例2: storiesOf

import { storiesOf, moduleMetadata } from '@storybook/angular';
import { withKnobs, text } from '@storybook/addon-knobs';

import { DummyService } from './moduleMetadata/dummy.service';
import { ServiceComponent } from './moduleMetadata/service.component';

storiesOf('Custom|Providers', module)
  .addDecorator(
    moduleMetadata({
      imports: [],
      schemas: [],
      declarations: [],
      providers: [DummyService],
    })
  )
  .add('Simple', () => ({
    component: ServiceComponent,
    props: {
      name: 'Static name',
    },
  }))
  .add(
    'With knobs',
    () => {
      const name = text('name', 'Dynamic knob');

      return {
        component: ServiceComponent,
        props: {
          name,
        },
開發者ID:chinmaymoharir,項目名稱:storybook,代碼行數:31,代碼來源:custom-providers.stories.ts

示例3: constructor

@Component({
  selector: 'storybook-comp-with-store',
  template: '<div>{{this.getSotreState()}}</div>',
})
class WithStoreComponent {
  private store: Store<any>;

  constructor(store: Store<any>) {
    this.store = store;
  }

  getSotreState() {
    return this.store === undefined ? 'Store is NOT injected' : 'Store is injected';
  }
}

storiesOf('ngrx|Store', module)
  .addDecorator(
    moduleMetadata({
      imports: [StoreModule.forRoot({})],
      declarations: [WithStoreComponent],
    })
  )
  .add('With component', () => ({
    component: WithStoreComponent,
  }))
  .add('With template', () => ({
    template: `<storybook-comp-with-store></storybook-comp-with-store>`,
  }));
開發者ID:chinmaymoharir,項目名稱:storybook,代碼行數:29,代碼來源:ngrx-store.stories.ts

示例4: storiesOf

import { storiesOf, moduleMetadata } from '@storybook/angular';
import { TokenComponent, ITEMS, DEFAULT_NAME } from './moduleMetadata/token.component';
import { CustomPipePipe } from './moduleMetadata/custom.pipe';

storiesOf('Metadata|Combined', module)
  .addDecorator(
    moduleMetadata({
      imports: [],
      declarations: [TokenComponent],
      providers: [
        {
          provide: ITEMS,
          useValue: ['Joe', 'Jane'],
        },
        {
          provide: DEFAULT_NAME,
          useValue: 'Provider Name',
        },
      ],
    })
  )
  .add('Combined 1', () => ({
    template: `<storybook-simple-token-component [name]="name"></storybook-simple-token-component>`,
    props: {
      name: 'Prop Name',
    },
  }))
  .add('Combined 2', () => ({
    template: `<storybook-simple-token-component [name]="name | customPipe"></storybook-simple-token-component>`,
    props: {
      name: 'Prop Name',
開發者ID:chinmaymoharir,項目名稱:storybook,代碼行數:31,代碼來源:metadata-combined.stories.ts

示例5: storiesOf

import { storiesOf, moduleMetadata } from '@storybook/angular';
import { withKnobs, text } from '@storybook/addon-knobs';

import { NameComponent } from './moduleMetadata/name.component';
import { CustomPipePipe } from './moduleMetadata/custom.pipe';

storiesOf('Custom|Pipes', module)
  .addDecorator(
    moduleMetadata({
      imports: [],
      schemas: [],
      declarations: [CustomPipePipe],
      providers: [],
    })
  )
  .add('Simple', () => ({
    component: NameComponent,
    props: {
      field: 'foobar',
    },
  }))
  .add(
    'With Knobs',
    () => ({
      component: NameComponent,
      props: {
        field: text('field', 'foobar'),
      },
    }),
    {
      decorators: [withKnobs],
開發者ID:chinmaymoharir,項目名稱:storybook,代碼行數:31,代碼來源:custom-pipes.stories.ts


注:本文中的@storybook/angular.moduleMetadata函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。