Hi, dropdown placeholder not rendered. I tried to switch to newest release 2.0.3, but the problem still exists, here is code:
<p-dropdown [options]="cities" [(ngModel)]="selectedCity" placeholder="Select a City" [style]="{'width' : '100%'}"></p-dropdown>
cities: SelectItem[];
selectedCity: string;
constructor() {
this.cities = [];
this.cities.push({ label: 'New York', value: { id: 1, name: 'New York', code: 'NY' } });
this.cities.push({ label: 'Rome', value: { id: 2, name: 'Rome', code: 'RM' } });
this.cities.push({ label: 'London', value: { id: 3, name: 'London', code: 'LDN' } });
this.cities.push({ label: 'Istanbul', value: { id: 4, name: 'Istanbul', code: 'IST' } });
this.cities.push({ label: 'Paris', value: { id: 5, name: 'Paris', code: 'PRS' } });
}
And in dropdown 1 element is NewYork, but selectedCity was never define in the code
Dropdown placeholder not redndered
-
- Posts: 1
- Joined: 23 Feb 2021, 10:12
Add optionValue attribute along with optionLabel to p-dropdown. Then it works.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 26 guests