角度:将下拉列表中的一个元素设置为readonly
假设我有一个下拉菜单,其中包含以下选项:“工作”,“释放”,“打开”。第二个选项“释放”应与“工作”和“打开”相比。我该怎么做?
模板看起来像这样:
<form [formGroup]="form">
<div class="flex">
<div class="col-3">
<div class="flex flex-row align-items-center">
<label class="col-6">Status</label>
<p-dropdown
[options]="workStatus"
[showClear]="true"
formControlName="workingStatus"
class="col-6">
</p-dropdown>
</div>
Let's say I have a dropdown menu, with the following options: "WORK", "RELEASE", "OPEN". The second option "RELEASE" should be readonly in contrast to "WORK" and "OPEN". How can I do this?
The template looks like this:
<form [formGroup]="form">
<div class="flex">
<div class="col-3">
<div class="flex flex-row align-items-center">
<label class="col-6">Status</label>
<p-dropdown
[options]="workStatus"
[showClear]="true"
formControlName="workingStatus"
class="col-6">
</p-dropdown>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用“ nofollow noreferrer”> primeng primeng文档,您可以使用OptionsLabel和optionsDisabled属性中指定的选项。
为此,您可以按以下方式定义数据:
并使用以下设置:
您可以检查更新的在这里示例
You can use options specified in the optionsLabel and optionsDisabled properties as described in PrimeNg documentation.
To do so, you can define your data as follow:
And use the follow settings:
You can check the updated sample here