我试图弄清楚当用户点击它时是否选中了复选框。
下面是代码
<ion-item-group>
<ion-item-divider color="light"><ion-icon name="warning" style="color:#FFBA55"></ion-icon> Overdue Tasks</ion-item-divider>
<ion-item> <ion-label class="label-style">item 1</ion-label>
<ion-checkbox (ionChange)="updateToDo($event)"></ion-checkbox></ion-item>
<ion-item> <ion-label class="label-style">item 2</ion-label>
<ion-checkbox (ionChange)="updateToDo($event)"></ion-checkbox></ion-item>
</ion-item-group>
updateTodo看起来像:
updateToDo(event){
alert(event.target.checked)
}
但是这会对事件上的目标属性抛出未定义的操作。
答案 0 :(得分:1)
我认为checked
是传递给函数的事件的属性。
您只需使用event.checked
代替event.target.checked
。