I'm currently developing a project in Angular 6 and I've encountered an issue with a dropdown in my template that is not working as expected:
<select id="companydropdown" onChange="getcompanyid(this)">
<option *ngFor="let company of filteredCompanies" value={{company.companyName}}
id={{company.id}}>
{{company.companyName}}
</option>
</select>
In my component, I have the following code:
getcompanyid(s)
{
var id = console.log(s[s.selectedIndex].id);
alert(id);
}
However, for some reason, the method does not seem to execute properly.