如何使用PrimeNG p表角度仅使一个单选按钮可点击



我正在使用PrimeNg表来显示我的项目。

<p-table *ngIf="certificates | async as certificates" [value]="certificates">
<ng-template pTemplate="header">
<tr>
<th style="max-width: 40%">Name</th>
<th style="max-width: 10%">Valid</th>
<th style="max-width: 10%">Active</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-certificate>
<p-skeleton *ngIf="loading"></p-skeleton>
<tr *ngIf="!loading">
<th>{{ certificate.name }}</th>
<td>{{ certificate.pac }}</td>
<td><i class="bi bi-check-lg"></i></td>
<td>
<input
(click)="getActiveStatus(certificate)"
[checked]="certificate.active"
type="radio"
/>
</td>
</tr>
</ng-template>
</p-table>

我希望只能选择一个单选按钮。现在我可以点击并选择所有的单选按钮,但我不希望出现这种情况。有人知道一次只能选择一个单选按钮吗?

尝试附加"name";所有单选按钮具有相同值的属性:

<input
(click)="getActiveStatus(certificate)"
[checked]="certificate.active"
type="radio"
name="group1"
/>

相关内容

最新更新