AngularJS HTML属性中的Typescript枚举

AngularJS HTML属性中的Typescript枚举,angularjs,typescript,Angularjs,Typescript,我在typescript中有一个枚举: enum EnumCountries{ Canada=0, USA=1, Holland=2 } 在AngularJS中,我希望在HTML中使用此选项,但以下选项不起作用: <div ng-show="model.country==EnumCountries.USA"> 我试图摆脱HTML中的神奇数字,为了在HTML中使用Enum,您需要指定一个Enum作为变量 您可以在component.ts中执行

我在typescript中有一个枚举:

 enum EnumCountries{
     Canada=0,
     USA=1,
     Holland=2
} 
在AngularJS中,我希望在HTML中使用此选项,但以下选项不起作用:

 <div ng-show="model.country==EnumCountries.USA">


我试图摆脱HTML中的神奇数字,为了在HTML中使用Enum,您需要指定一个Enum作为变量

您可以在component.ts中执行以下操作:

enumCountries = EnumCountries;
然后在component.html中,您可以执行以下操作:

<div ng-show="model.country == enumCountries.USA">

您需要将枚举类分配给
$scope
变量-
$scope.EnumCountries=EnumCountries