Using * ngFor with ng container and * ngIf
One section of my form contains a set of n radio buttons (here we will set n = 3), which appear in the template as:
<input type="radio" name="variety" value="11" (click)="update($event)">SomeNameX
<input type="radio" name="variety" value="23" (click)="update($event)">SomeNameY
<input type="radio" name="variety" value="36" (click)="update($event)">SomeNameZ
Below the radio buttons, I want to create one of them when the corresponding SomeName is selected:
<div *ngIf="selected===11">Last updated: Sept 1</div>
<div *ngIf="selected===23">Last updated: Oct 3</div>
<div *ngIf="selected===36">Last updated: Nov 4</div>
where the date and value for each SomeName is returned from the database. I use the following code to make this work:
<ng-container *ngFor="let item of items;">
<div
*ngIf="selected==={{item.id}}"
>Last updated: {{item.dte}}</div>
</ng-container>
It doesn't work because of the {{item.id}} element - how can I enter the correct value / id at this position?
Thanks / Tom.
+3
source to share