'How to inject data into TemplateRef in Angular?

Given is a popover service that can display any component as a popup. The service accepts a TemplateRef.

export type PopoverContent = TemplateRef<any> | Type<any> | string;
export class PopoverRef<T = any> {
  constructor(public overlay: OverlayRef,
              public content: PopoverContent) {

I use it like this:

this.popover.open(content: FooComponent, ...);

I am trying to figure out how to inject data to this service, that I would normally inject through the HTML directives, e.g:

    <foo [data]="'hello world'">


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source