Primeng: Drop down list onChange not working

Created on 21 Mar 2017  路  9Comments  路  Source: primefaces/primeng

Current behavior

The onChange event is not been called.

Expected behavior
onChange callback should be called.

  • Angular version: 2.0.X
    2.4.10

  • PrimeNG version: 2.0.X
    2.0.5

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    Typescript

Most helpful comment

works without $event

<p-dropdown [options]="languages" [(ngModel)]="value" (onChange)="onChange()" [autoWidth]="false"> </p-dropdown>

All 9 comments

Have the same issue:
<p-dropdown [options]="dropdownAccounts" [(ngModel)]="selectedAccount" [style]="{'width':'150px'}" (onChange)="onAccountSelect"> </p-dropdown>

Angular: 2.4.6
PrimeNG: 2.0.4

I solve the problem, instead of (onChange)="onAccountSelect" should be (onChange)="onAccountSelect($event.value)"

works without $event

<p-dropdown [options]="languages" [(ngModel)]="value" (onChange)="onChange()" [autoWidth]="false"> </p-dropdown>

My (onChange) event gets fired even if I select the same item once again. Technically, it is not a change from the previous selection so this shouldn't happen.

Can somebody verify this?

Can somebody verify this?

yes, (onChange) is fired if I select the same item once again

my code
<p-dropdown [options]="countries" [(ngModel)]="value" (onChange)="onChange()" [autoWidth]="false"> </p-dropdown>
countries.push({label: 'Bitte w盲hlen', value: null}); countries.push({label: 'Deutschland', value: 'DE'}); countries.push({label: '脰sterreich', value: 'AT'});

Thanks @cyberrranger
In this case an issue needs to be raised for this. This behavior is actually not correct and needs to be corrected.

Tracked at #2760

Hello i was wondering if i wanted to fire the onChange event whiel selecting same item how could i do it?

please add a condition and use the findIndex array method based on the index implement the conditional flow of selection code execution

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Faigjaz picture Faigjaz  路  3Comments

pchristou picture pchristou  路  3Comments

papiroca-tm picture papiroca-tm  路  3Comments

garethlewis picture garethlewis  路  3Comments

Helayxa picture Helayxa  路  3Comments