For reference using libaray : https://www.primefaces.org/primeng/#/dropdown
The issue is that the select shows the first option but according to the backend the field is undefined.
<p-dropdown [options]="avaliableTemplates" [style]="{'width':'100%'}" required placeholder="Select Title" filter [(ngModel)]="selectedTemplate" name="selectedTemplate"></p-dropdown>
Here is the code that checks on change:
@ViewChild('createCampaignForm') form;
this.form.control.valueChanges.debounceTime(1000).subscribe(values => this.doValidation(values));
Here's how I am assigning avaliableTamplates
this.campaignService.getTemplates(this.authService).subscribe(x => {
this.avaliableTemplates = [];
for (var i = 0; i < x.length; i++) {
this.avaliableTemplates.push({
label: x[i].title,
value: x[i].id
});
}
});
Based on the above it seems like the drop down doesn't default to undefined but the first element in the array. But it doesn't even recognize that the first element is selected in the back end.
