Dartlang: Using enums in Angular2 templates


can someone tell me if and how it is possible to use Dart enums in angular2 view templates?

It’s suggested in Typescript to copy the enum into a component-scope.
This works because an enum in javascript is a simple instance variable with a prototype.

But since enums in dart are first class citizens, they cannot be moved to an instance variable.

Thanks in advance!


We’re working on bringing formal support, but you can always add a getter for now:

enum MyEnum {

class MyComponent {
  MyEnum get stateA => MyEnum.stateA;

Answered By – matanlurey

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *