I am data binding a collection to the prime NG dropdown.
<p-dropdown [options]="statusTypes" formControlName="StatusTypeCode" optionLabel="Name">
</p-dropdown>
I am setting the formControlName to this dropdown, which works great. The only problem is that the form sets the entire object (example: statusTypes[2]). I want the form to specify a value for the selected value, instead of the entire object (example: statusTypes[2].StatusTypeCode)
I know I can recreate the options before setting them...
this.statusTypes= [];
for (let statusType of this.allStatusTypes) {
this.statusTypes.push({ label: (statusType.Name), value: statusType.StatusTypeCode });
}
but then I have to do that on every drop down collection!
Is there any way in the HTML to just specify the value of the dropdown equal to a property (example: optionValue="StatusTypeCode") so I can have the form populate with the id instead of the entire object?