context: object
The object’s keys will be available for binding by the local template let
declarations.- Using the key
$implicit
in the context object will set its value as default
.
<ng-container *ngTemplateOutlet="test1; context: { $implicit: 'World', name: 'Lorie' }"></ng-container>
<hr>
<ng-container *ngTemplateOutlet="test2; context: { $implicit: 'World', name: 'Lorie' }"></ng-container>
<hr>
<ng-container *ngTemplateOutlet="test3; context: { $implicit: 'World', name: 'Lorie' }"></ng-container>
<ng-template #test1 let-name let-age><span>test1 - Hello {{name}}! $implicit is {{age}}!</span></ng-template>
<ng-template #test2 let-name="name" let-age><span>test2 - Hello {{name}}! $implicit is {{age}}!</span></ng-template>
<ng-template #test3 let-myName="name" let-age><span>test3 -Hello {{myName}}! $implicit is {{age}}!</span></ng-template>