I need your help. I have a small piece of code. In my template I have select
from option
in which I save the list of settings. Each individual setting has its own id
. I also have an interface through which I have a data model - the fields that I will send or receive from the backend. Please help with the task: how do I get the id
option I choose and send it in the optionId
field? Thank you very much
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);
}