How to use a typescript enum value in an Angular2 ngSwitch statement

后端 未结 9 697
深忆病人
深忆病人 2020-12-07 16:13

The Typescript enum seems a natural match with Angular2\'s ngSwitch directive. But when I try to use an enum in my component\'s template, I get \"Cannot read property \'xxx

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 16:47

    This's simple and works like a charm :) just declare your enum like this and you can use it on HTML template

      statusEnum: typeof StatusEnum = StatusEnum;
    

提交回复
热议问题