Can you assist me with a coding issue? In my template, I have a select dropdown with options saved in a list of settings. Each setting has its own unique id. I also have a data model in my interface for fields sent or received from the backend. How can I extract the id of the selected option and send it to the optionId field? Thank you for your help.
interface.ts
export interface IData {
id: string;
name: string;
optionId: any;
}
html
<select formControlName="templateListValue">
<option *ngFor="let tempItem of templateListOptions" [value]="templateItem.id">
{{tempItem.name}}
</option>
</select>
ts
public getIdFromTemplate() {
return this.templateListOptions.find
((element: ITemplateData) => element.id === this.form.controls.templateListValue.value);
}