【发布时间】:2014-10-18 05:52:26
【问题描述】:
在 Typescript 中,我创建了一个这样的枚举:
enum Action { None = 0, Registering = 1, Authenticating = 2 };
在我的控制器中,我设置了一个名为 action 的属性,如下所示:
class AuthService implements IAuthService {
action: number;
constructor(
private $state,
private userService,
private utilityService: IUtilityService
) {
this.action = Action.None;
}
doRegister() => {
this.action = Action.Registering;
}
这很好用,但我如何在我的 HTML 中使用枚举。那可能吗?我想做的是在这样的地方使用它:
<span ng-class="{'fa-spin fa-spinner': app.authService.authenticating }">
无需为以下各项创建不同的变量:
app.authService.authenticating
app.authService.registering
...
etc
【问题讨论】:
标签: angularjs typescript