I Found this when searching for "using enums in Angular templates" as I was getting a type error when doing an AOT build:
Argument of type 'string' is not assignable to parameter of type 'MyEnumName'.
I did indeed need to convert my enum to an array of strings in order to compare against another string value, which I did using Object.values() rather than Object.keys() as mentioned in your article:
public myArray = Object.values(MyEnumName).map(item => String(item));
Nice article!
I Found this when searching for "using enums in Angular templates" as I was getting a type error when doing an AOT build:
I did indeed need to convert my enum to an array of strings in order to compare against another string value, which I did using
Object.values()
rather thanObject.keys()
as mentioned in your article:Pretty sure
.values
and.keys
will do the same thing if you have your enum declare with a string value as followsI assume you just have your enum declared like the below