2

我正在尝试制作一个使用将 aTemplateRef作为@Input. 但我不知道怎么做。

测试组件

@Component({
  selector: 'test',
  templateUrl: './test.component.html',
})
export class TestComponent {
  @Input() public set value(value: TemplateRef<void>) {
    // ...
  }
}

故事

export default {
  title: 'Components/Test',
  component: TestComponent,
} as Meta;

const Template: Story<TestComponent> = (args) => ({
  props: args,
});

export const TemplateRefStory = Template.bind({});
TemplateRefStory.args = {
  value: ???, // <-- what do I put here?
};

我尝试了很多东西,它们与下面的类似。这真的没有意义。

export const TemplateRef: Story<TestComponent> = (args) => ({
  template: `<ng-template #hello>Hello</ng-template>`,
  props: args,
});

TemplateRef.args = {
  value: '#hello',
};
4

0 回答 0