Angular:如何隐藏 PrimeNG 下拉所选选项?
我需要我的 p-dropdown 隐藏先前选择的选项。
例如,我有选项a
,b
和c
。如果我先前选择了a
,则仅B
和C
应显示在下拉列表中。然后,如果我选择b
,现在只能显示 a a c 。
//component.ts
this.planOptions = [
{ name: 'A'},
{ name: 'B'},
{ name: 'C'}
];
//component.html
<p-dropdown id="plan_option"
[options]="planOptions
[(ngModel)]="selectedPlanOption"
optionLabel="name">
</p-dropdown>
I need my p-dropdown to hide the previously selected option.
For example, I have options A
, B
, and C
. If I previously selected A
, only B
and C
should show up in the dropdown list. Then if I select B
, now only A
and C
should show up.
//component.ts
this.planOptions = [
{ name: 'A'},
{ name: 'B'},
{ name: 'C'}
];
//component.html
<p-dropdown id="plan_option"
[options]="planOptions
[(ngModel)]="selectedPlanOption"
optionLabel="name">
</p-dropdown>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该创建一个只包含可能选项的PlanOptions的副本
TS文件
HTML文件
You should create a copy of planOptions that contains only the possible options
TS File
HTML File
您可以将选项拼接,然后用CSS隐藏
&lt; li&gt;
。然后
You can splice the options and then hide the
<li>
with css.Then