I want to bind an enum as options in a HTML selector
export enum MY_ENUM{
ONE = 'One',
TWO = 'Two',
THREE = 'Three'
}
How do I bind this as options for my HTML select using ngFor
I would use Object.values to get a list of the enum values like so:
this.options = Object.value(MY_ENUM);
And then in the template
<select>
<option *ngFor="let option of options" [value]="option">{{option}}</option>
</select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With