PrimeNg p-dropdown Does not Display Array Values

Ariela picture Ariela · Mar 20, 2018 · Viewed 10.6k times · Source

I have component using PrimeNg p-dropdown.
html code:

<p-dropdown [style]="{'width':'150px'}" [options]="portNames" placeholder="Select a Port">
</p-dropdown>

ts portNames decleration:

portNames: string[] =["Port 01","Port 02", "Port 03"];

My Problem is that DropDown Does not Display Values "Port 01","Port 02", "Port 03".

Maybe I have any mistake?

Answer

Mancy Saxena picture Mancy Saxena · Mar 20, 2018

Try adding your dropdown values in label and values

portNames =[
{label:'Port 01', value:'Port 01'},
{label:'Port 02', value:'Port 02'},
{label:'Port 03', value:'Port 03'},
];