0

I'm trying to convert a Typescript enum value to a number so that in my dropdown it shows the enum string value but on a submit button, the value is passed instead of the string. The enum is set up as below.

As of now I'm able to console.log the key (string) of the object (ex. Value), but what I would like to do is pass the 0 (numeric) value once the object is emitted.

How would I do that?

enum Value {

Value = 0,
Test = 1,
Foo, 2

}
0

1 Answer 1

0

You need the reverse mapping, see here in the docs, basically:

Value[Value.Value] = "Value"
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.