When I run the below, Colors.RED
seemingly resolves to something falsy because the color
attribute of the div doesn’t even appear in the rendered HTML (though if I switch it to the string literal color="red"
, it renders just fine). How can I fix this?
However, there seems to be no problem with Colors.BLUE
resolving to the string blue
and it populates the text area of the div with no problems (so long as you have the line Colors = Colors;
).
I don’t understand why the string interpolation w/ string enum works in the body of the div, but not in the attribute assignment.
app.ts
export class App {
Colors = Colors;
constructor() {}
}
export enum Colors {
RED = 'red',
BLUE = 'blue'
}
app.html
<template>
<div color="${Colors.RED}">
${Colors.BLUE}
</div>
</template>