Angular / PrimeNG:如何在p-radiobutton中使用ng-template

时间:2017-12-12 14:55:17

标签: angular primeng

我试图在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>

1 个答案:

答案 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>