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
My solution was to have the countries loaded in the controller before setting the form field (ngModel or formControl). Also keep the same type of the key. Don't use number for the form control and string for the list:
// first get the cities from the server
response.cities.forEach(city => {
this.dropdowns['cities'].push({ value: city.id, label: element.city }); });
// when setting the form
city_id: new FormControl(this.user.city_id)
In the code above this.user.city_id and city.id has the same type number