我有一個包含 2 個選項的下拉串列:

我希望用戶能夠看到兩個選項(Cips、Projects);但是,我不想讓用戶選擇不同的專案。
我們如何允許用戶單擊下拉串列并查看所有選項,但禁止選擇任何其他選項?
這個下拉選單的定義如下:
<p-dropdown [(ngModel)]="editRagColumns.BaseObjectType"
name="RagBasicType"
type="text"
class="form-control"
id="RagBasicType"
[options]="baseObjectTypes"
optionLabel="BaseObjectTypeName"
[style]="{'width':'100%', 'border-color':'transparent'}"
>
</p-dropdown>
uj5u.com熱心網友回復:
根據檔案:https : //www.primefaces.org/primeng/showcase/#/dropdown
你可以用這個 optionDisabled
uj5u.com熱心網友回復:
您必須將以下屬性添加到“p-dropdown”組件中。
optionDisabled="BaseObjectTypeName"
這是我所做的 ts 和 html 檔案,以確認它有效。
.ts 檔案
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-question1',
templateUrl: './question1.component.html',
styleUrls: ['./question1.component.sass']
})
export class Question1Component implements OnInit {
BaseObjectTypeName: string = "BaseObjectTypeName";
baseObjectTypes: any[] = [
{ BaseObjectTypeName: "tab1" },
{ BaseObjectTypeName: "tab2" },
];
constructor() { }
ngOnInit(): void {
}
}
html檔案
<p-dropdown
name="RagBasicType"
type="text"
class="form-control"
id="RagBasicType"
[options]="baseObjectTypes"
optionLabel="BaseObjectTypeName"
[style]="{'width':'100%', 'border-color':'transparent'}"
optionDisabled="BaseObjectTypeName"
>
</p-dropdown>
我希望我已經幫助了你。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/404693.html
標籤:
