Right now this is my implementation for primeng dropdown -
cust.component.html -
<p-dropdown #dd1 [options]="custList" [ngModel]="selectedCust" placeholder="Select Account Id"
[style]="{'width':'200px'}" name="selectDropDown" optionLabel="userName"
(onChange)="dd1.value = changeCust($event.value)"></p-dropdown>
cust.component.ts -
private currentVal:Customer;
..
..
changeDEA(cust: Customer) {
var cfg = confirm("This action will stop the file upload. Do you still want to continue? ");
if(cfg){
this.currentVal = cust;
// Proceed with normal change event
}else{
console.log("user cancelled skip..");
this.selectedCust = this.currentVal;
// Should revert back to original value
return this.selectedCust;
}
Problem is that the view value shown in the screen is not being reverted to original value.
Expected Result -
Dropdown changes from Value A to Value B.
User confirmation - Select "Cancel".
Page should still show the old value i.e Value A.
Actual result -
Dropdown changes from Value A to Value B.
User confirmation - Select "Cancel".
Page should is showing new value B. (without primeng, its showing blank value - https://stackblitz.com/edit/angular-dropwdown-confirmation-issue)
Adding GIF -
Came across this code which works fine with native angular but fails when options are populated dyamically with *ngFor - https://stackblitz.com/edit/angular-dropwdown-confirmation-issue
FYI, tried various github posts but none of them found useful.
Angular Version - "@angular/core": "^5.2.0"
PrimeNG - "primeng": "^5.2.4"
