0
votes

Is there any option to pass/use angular TemplateRef from component in angular Service ? I use https://ng.ant.design/components/message/en, it has a method: this.message.success('text'); instead of 'text' i can pass TemplateRef. Is there an option to pass here TemplateRef from a component ? Or maybe any other ideas to handle this ?

1

1 Answers

0
votes

You can use ViewChild:

@Component({
  selector: 'example',
  template: '<template #templateRef>xxx</template>'
})
class ExampleComponent {
  @ViewChild('templateRef') templateRef:TemplateRef;

  constructor(private teplateService: TemplateService) { }

  onAction() {
    this.someService.sendTemplate(this.template1);
  }
}