【发布时间】:2021-03-18 19:45:59
【问题描述】:
我想要一个 p-selectButton 单选按钮,可以取消选中一个选项。
如果多个设置为 true,则可以取消选中一个选项,但可以选择多个选项。将多个设置为 false 时,无法选择多个选项,但我无法取消选中一个选项。
这行得通:
<p-selectButton [multiple]="true" (onChange)="onChange()" [options]="options"></p-selectButton>
onChange() {
// choose the last option
// (as the newly selected one is always added at the end of the array)
}
有没有更简单的解决方案?
【问题讨论】: