0

I want to get all selected option or value from the array list. I'm getting the list and display them in checkbox list, I'm selecting and deselecting checkbox.so when I submit, I just want only selected checkbox value. Here is code of html page:

     <ion-item *ngFor="let job of jobs; let i= index"   >
          <ion-label >{{job.Des_Name}}</ion-label>
          <ion-checkbox ></ion-checkbox>
        </ion-item>

when click I want only selected checkboxes list or positions suppose I had selected 1,2,5 position I want that only list

99tharun
  • 1,216
  • 3
  • 20
  • 36
androidking
  • 207
  • 5
  • 17
  • Possible duplicate of [Ionic 2 Multiple Checkboxes with FormBuilder](https://stackoverflow.com/questions/44302163/ionic-2-multiple-checkboxes-with-formbuilder) – 99tharun Oct 06 '17 at 21:00

1 Answers1

1

In your .ts file:

jobs = [
{
  Des_Name: 'name1',
},
{
  Des_Name: 'name2',
},
{
  Des_Name: 'name3',
},
{
  Des_Name: 'name4',
},
];

do_sth(index) {
   console.log(index);
   //you can find the selected job
}

and in you .html file:

<ion-item *ngFor="let job of jobs; let i= index">
    <ion-label>{{job.Des_Name}}</ion-label>
    <ion-checkbox (ionChange)="do_sth(i)"></ion-checkbox>
</ion-item>
amin arghavani
  • 1,883
  • 14
  • 21