1
我從我的數據庫中填充複選框,並且我希望用戶能夠完成複選框表單並將其提交回數據庫。我無法弄清楚如何獲取動態填充的複選框的值。代碼如下。Ionic 2獲取動態複選框的值
export class ListPage {
checklists: any;
checkedData: any;
checklist:any;
a:any;
constructor(public navCtrl: NavController, public navParams:
NavParams, public http: Http, public data: checklistData) {
this.data.checklistdata().then(result => {
this.checklists = result;
console.log(this.checklists)
});
for(this.a=0; this.a>0; this.a++){
console.log(this.checklist.checked)
}
}
}
<div *ngFor="let checklist of checklists; let i=index ">
<ion-item>
<ion-label>{{checklist.name}}</ion-label>
<ion-checkbox [(ngModel)]="checklist.checked"></ion-checkbox>
</ion-item>
</div>
<b>selectedItems</b>: <div *ngFor="let checklist of checklists">{{checklist.checked}}</div>