primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
10.03k stars 4.53k forks source link

Dropdown: Binding to type no longer works (regression) #14089

Closed pkdigital closed 9 months ago

pkdigital commented 9 months ago

Describe the bug

When binding an array of a data to the p-dropdown control and that data value field is a typescript type the control is unable to display the corresponding name member.

Environment

Primeng 16.7.2 Angular 16.2.0

Reproducer

https://stackblitz.com/edit/bpr5uy-vq3hq7?file=src%2Fapp%2Fdemo%2Fdropdown-basic-demo.html

Angular version

16.2.0

PrimeNG version

16.7.2

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18

Browser(s)

Any

Steps to reproduce the behavior

Control markup

<p-dropdown
    [options]="cities"
    [(ngModel)]="selectedCityCode"
    optionLabel="name"
    optionValue="code"
    showClear="true"
    placeholder="Select a City"
  ></p-dropdown>

Type definition

type CityCode = 'NY' | 'LDN' | 'RM' | 'IST' | 'PRS';

Bound values

cities: { name: string; code: CityCode }[] = [
        { name: 'New York', code: 'NY' },
        { name: 'Rome', code: 'RM' },
        { name: 'London', code: 'LDN' },
        { name: 'Istanbul', code: 'IST' },
        { name: 'Paris', code: 'PRS' }        
    ];

Output:

image

Expected behavior

No response

pkdigital commented 9 months ago

Sorry, just realised this is a dupe of #14054