Как внедрить сервисы в угловые сборники рассказов? - PullRequest
0 голосов
/ 31 октября 2019

Github: https://github.com/danielhdz56/storybook-demo.git

Внедрение службы в компонент всегда вызывает ошибку в сборнике рассказов:

Error: Can't resolve all parameters for CustomService: (?).

пример компонента:

 @Component({
   selector: 'app-custom-selector',
   templateUrl: './custom-selector.component.html',
   styleUrls: ['./custom-selector.component.scss'],
 })
 export class NavigationItemComponent {
   constructor(private customService: CustomService) {}
 }

1 Ответ

0 голосов
/ 31 октября 2019

Вам нужно добавить их в модуль metaData

const modules = {
    imports: [..],
    providers: [CustomService],
    declarations: [NavigationItemComponent ]
};

// Then in stories: 
.add('description',
    () => ({
        component: NavigationItemComponent ,
        props: {...},
        moduleMetadata: modules
    }
)
...