我试图在sponsrtype.id == 2时显示问号图标但是我的ng-template似乎不起作用。知道我在下面做什么有什么问题吗?
<span *ngFor="let sponsorType of sponsorTypes; let i = index">
<p-radioButton name="sponsorType" formControlName="{{ i }}" [value]="sponsorType.id" [label]="sponsorType.description" [(ngModel)]="selectedSponsor.sponsorTypeId">
<ng-template let-sponsor pTemplate="item">
<i class="fa fa-question-circle" *ngIf="sponsor.id == 2" aria-hidden="true"></i><i class="fa fa-question-circle" aria-hidden="true"></i>
<a class="infoLink smallTxt" >What is apples?</a>
</ng-template>
</p-radioButton>
</span>
答案 0 :(得分:0)
因为您无法在ng-template
内使用p-radioButton
,所以您可以执行以下操作:
<span *ngFor="let sponsorType of sponsorTypes; let i = index">
<p-radioButton name="sponsorType" formControlName="{{ i }}" [value]="sponsorType.id" [label]="sponsorType.description" [(ngModel)]="selectedSponsor.sponsorTypeId"></p-radioButton>
<span *ngIf="sponsorType.id == 2">
<i class="fa fa-question-circle" aria-hidden="true"></i>
<a class="infoLink smallTxt" >What is apples?</a>
</span>
</span>