相关疑难解决方法(0)

在控制器功能中未定义角度模板枚举

我在angular(4)app中有以下内容:

export enum RegisterAccomodationStatus {
    noFixedAbode = 1,
    sofaSurfing = 2,
    accommodation = 3,
    other = 4
}
Run Code Online (Sandbox Code Playgroud)

在我的模板中,我有:

<button (click)="setCurrentAccomStatus(attendance, registerAccomodationStatus.noFixedAbode)" type="button" class="btn btn-default">NFA</button>
<button (click)="setCurrentAccomStatus(attendance, registerAccomodationStatus.sofaSurfing)" type="button" class="btn btn-default">Sofa</button>
Run Code Online (Sandbox Code Playgroud)

我在我的组件中设置了一个属性:

registerAccomodationStatus: RegisterAccomodationStatus = RegisterAccomodationStatus.other;
Run Code Online (Sandbox Code Playgroud)

最后我的功能:

setCurrentAccomStatus(registerAttendance: RegisterAttendance, accomStatusId: RegisterAccomodationStatus) {
        console.log(accomStatusId);
        registerAttendance.accomodationStatus = accomStatusId;

        this.registerService.updateGuestAttendance(registerAttendance)
            .subscribe(registerAtt => registerAttendance = registerAtt);
    }
Run Code Online (Sandbox Code Playgroud)

当点击其中一个按钮时console.log(accomStatusId);,undefined我正在按照我在网上找到的示例来执行此操作.

我究竟做错了什么?

angular

0
推荐指数
1
解决办法
1529
查看次数

标签 统计

angular ×1