我在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 ×1