vendredi 8 septembre 2017

Ionic 2 get value of dynamic checkboxes

I am populating checkboxes from my database, and I want the user to be able to complete the checkbox form and submit it back to the database. I am unable to figure out how to get the values of the checkboxes that are populated dynamically. The code is below.

    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></ion-label>
          <ion-checkbox [(ngModel)]="checklist.checked"></ion-checkbox>
         </ion-item>
        </div>

        <b>selectedItems</b>: <div *ngFor="let checklist of checklists"></div>




Aucun commentaire:

Enregistrer un commentaire