【发布时间】:2018-09-10 17:27:03
【问题描述】:
我有一个嵌套的 ngFor Checkbox.. 我只需要设置 NgModel 来检查复选框是否被选中??
<ion-item-group *ngFor="let patient of Patients; let i= index">
<ion-item-divider color="light">{{patient.conditionGroup}}</ion-item-divider>
<ion-item *ngFor="let condition of patient.conditions; let j= index">
<ion-label>{{condition}}</ion-label>
<ion-checkbox id="{{condition}}" [(ngModel)]="checkStatus[i][j]" (ionChange)="mylist(i,j,condition)" color="danger"></ion-checkbox>
</ion-item>
</ion-item-group>
我的控制器是这样的..
{
this.checkStatus=[];
this.Patients = [];
for(var s=0;s<this.Patients.length;s++)
{this.checkStatus[s]=[];}
}
How do i check if the checkbox is checked.. error
ERROR TypeError: Cannot read property '0' of undefined
患者
[
{
"conditionGroup": "Family Care",
"conditions": [
"Head",
"Poisoning",
"Stroke"
]
}
]
在 myList() 中,我需要将选中的选项推送到数组中..
【问题讨论】:
-
请清楚地描述你的工作..
-
更新对象数组的患者 .... 并更新 mylist 函数
-
感谢回复
-
欢迎@karthika
-
你需要将条件存储在数组中或者还需要索引......
标签: angular ionic3 ngfor ion-checkbox