Display dropdown with an existing value.

UI Components for Angular
Post Reply
mathewcornelius
Posts: 2
Joined: 25 May 2016, 08:37

11 Nov 2016, 10:22

suppose i have a employee information screen with city as a dropdown, i select a city (say NY) and store in the DB. when i pull this record later on for editing , the city dropdown should display NY.

how do i achieve this?

<p-dropdown [options]="arrCityDropDown" [(ngModel)]="selectedCity" filter="true"
(onChange)="onChange_City($event)" [style]="{'width':'100%'}"></p-dropdown>

am i missing something?

thanks in advance.

User avatar
DarthMaul
Posts: 582
Joined: 23 Nov 2015, 21:20

11 Nov 2016, 12:54

Hi,

In your ts file selectedCity should point to your preselected value.

For example;

selectedCity: string = 'New York';

Dropdown will show default value selected at the beginning.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests