Is there a way to retrieve the key of an enum not as a string, but with the enum itself? https://stackblitz.com/edit/typescript-av8rkx
enum Widgets {
Foo = "this is foo",
Bar = "this is bar"
}
const current = "this is foo";
console.info(current); // 'this is foo';
let enumKey = Object.keys(Widgets)[Object.values(Widgets).indexOf(current)];
console.log(typeof(enumKey)) // here it returns string
I want to be able to access the enum using the 'enumKey' mentioned above.
Widgets[enumKey]
Unfortunately, this method is not working for me. Can anyone provide assistance on how to achieve this? Thanks