有没有办法为 Angular 组件编写故事书故事,以便将内部 html/文本嵌入到渲染的故事书中?
在这里,我的尝试是在没有嵌入的测试内部文本的情况下呈现的
按钮组件:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'open-button',
templateUrl: './button.component.html',
styleUrls: ['./button.component.scss']
})
export class ButtonComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
按钮组件模板:
<button type="button">
<ng-content></ng-content>
</button>
故事:
storiesOf('Button', module)
.add('Basic Button', () => ({
component: ButtonComponent,
template:
`
<open-button class="primary" type="button">testing</open-button>
`,
}));
渲染为:
<open-button _nghost-c8="">
<button _ngcontent-c8="" type="button">
</button>
</open-button>