in Angular by
How can you rework the way you use ngif in the below syntax of code using an ng-template element?

<div *ngIF="mediaItem.watchedOn">Watched on {{ mediaItem.watchedOn }}</div>

1. <ng-template [ngIf]='mediaItem.watchedOn'>

     <div>Watched on "mediaItem.watchedOn"</div>

</ng-template>

2. <ng-template [ngIf]="mediaItem.watchedOn">

     <div>Watched on

3. <ng-template (ngIf)='mediaItem.watchedOn'>

     <div>Watched on 'mediaItem.watchedOn'</div>

</ng-template>

4. <ng-template (ngIf)="mediaItem.watchedOn">

     <div>Watched on [ mediaItem.watchedOn ]</div>

</ng-template>

1 Answer

0 votes
by

Correct answer is :- 

<ng-template [ngIf]="mediaItem.watchedOn">

<div>Watched on {{ mediaItem.watchedOn }}</div>

</ng-template>

...