<select (change)="select($event.target.value)" [ngModel]="gen"
class="border border-gray-200 bg-white h-10 pl-6 pr-40 rounded-lg text-sm focus:outline-none appearance-none block cursor-pointer"
id="gender" required>
<option value="" disabled="true" selected hidden>Select Gen</option>
<option [value]="{ id: g.id, name: g.name }" *ngFor="let g of genObj">{{g.name}}</option>
</select>
selectGenre({id,name}): void {
console.log(id,name,'genre')
}
genObj -
0: {id: 2, name: "xcv"}
1: {id: 3, name: "ert"}
Is there a way to extract both ID and name values when selecting from the dropdown menu? I tried passing 'g.id' and 'g.name' but ended up getting undefined for both.