ngTemplateOutlet directive
This is the documentation for Angular 6.
You can switch to the latest version Angular 10.
You can switch to the latest version Angular 10.
Inserts an embedded view from a prepared TemplateRef.
Source
<ng-container *ngTemplateOutlet="greet"></ng-container>
<hr>
<ng-container *ngTemplateOutlet="eng; context: myContext"></ng-container>
<hr>
<ng-container *ngTemplateOutlet="svk; context: myContext"></ng-container>
<hr>
<ng-template #greet>
<span>Hello</span>
</ng-template>
<ng-template #eng let-name>
<span>Hello {{name}}!</span>
</ng-template>
<ng-template #svk let-person="localSk">
<span>Ahoj {{person}}!</span>
</ng-template>
export class AppComponent {
myContext = {$implicit: 'World', localSk: 'Svet'};
}
Result
Hello World!
Ahoj Svet!
Using the key $implicit
in the context object will set its value as default.