change content of <ng-template> programmatically from a component

1.3k Views Asked by At

EDITED

i got reference to a by a template variable in its component.

<ng-template #templateLogGroup>Logs Group</ng-template>

@ViewChild('templateLogGroup') templateLogGroup : TemplateRef<any>;

Now, how can i change the content dynamically in a method of the controller?

i'm trying to do in this way: this.templateLogGroup.elementRef.nativeElement.innerHtml = "<strong>changed<strong>";

but on the screen nothing is changed.

On the other hand, if i print to the console the content of "templateLogGroup" i can notice that the conthent of templateLogGroup.elementRef.nativeElement.innerHtml is changed.

So seems that this operation doesn't fire the rendering

this is the code: https://stackblitz.com/github/pinale/changetemplatecontent

0

There are 0 best solutions below