Variables in ng-container/ng-template

https://www.notion.so/Variables-in-ng-container-ng-template-fab1314c12924d5aa22de15db7844efd

1
2
3
<div>
  <ng-container *ngTemplateOutlet="viewTemplate; content: {$implicit: {name: 'Bing'}}"></ng-container>
</div>
1
2
3
4
5
6
@Component({
	selector: 'sub',
})
export class SubComponent {
	@Input() viewTemplate: TemplateRef<any>;
}

bookmark

How to use:

1
2
3
4
5
<sub [viewTemplate]="view"></sub>

<ng-template #view let-data>
   Your name 
</ng-template>

bookmark

This post is licensed under CC BY 4.0 by the author.