Angular 6 ngTemplateOutlet inside ngFor multiple context
I also mentioned that on the official github repository of Angular. The correct answer by the devs was:
@dawidgarus: You can do:
<ng-container *ngTemplateOutlet="incomingTemplate;context:{ todo: todo, templateService: libService }">
In addition:
@dawidgarus suggestion is a good one and follows how scoping works in current Angular - I don't think we want to re-visit it. The only thing I would suggest is to use
<ng-template>
element instead of <ng-container>
as it generates less code, doesn't create unnecessary comment nodes in the DOM etc.:
<ng-template [ngTemplateOutlet]="incomingTemplate" [ngTemplateOutletContext]="{ todo: todo, templateService: libService }">
so I used ng-template instead of ng-container.
Cheers