I am using PrimeNG in my angular5 app. I have issue with p-dropdown
Question
I have p-dropdown for showing countries. I bind the select opti
Update in PrimgNg
While setting default value for dropdown in Primeng need to be little careful.
<p-dropdown name="country" [options]="countries" [(ngModel)]="country" placeholder="select country" (onChange)="changeCountry()"></p-dropdown>
country
should be a number
not string.
You can typecast it, if it is a string.
country: Number("1");
Try to replace
this.applicant.country = 'India';
with
this.applicant = {country: 'India'};
Edit
Display your p-dropdown
once you got the data from your API.
<div *ngIf="dataLoaded">
<p-dropdown [options]="countries" [(ngModel)]="applicant.country"></p-dropdown>
</div>
See Plunker