How to set Alert checkbox values and label to loop and display from server

This is the sample from ionic 2

doCheckbox() {
  let alert = this.alertCtrl.create();
  alert.setTitle('Which planets have you visited?');

alert.addInput({
  type: 'checkbox',
  label: 'Alderaan',
  value: 'value1',
  checked: true
});

alert.addInput({
  type: 'checkbox',
  label: 'Bespin',
  value: 'value2'
});

alert.addInput({
  type: 'checkbox',
  label: 'Coruscant',
  value: 'value3'
});

alert.addInput({
  type: 'checkbox',
  label: 'Endor',
  value: 'value4'
});

alert.addInput({
  type: 'checkbox',
  label: 'Hoth',
  value: 'value5'
});

alert.addInput({
  type: 'checkbox',
  label: 'Jakku',
  value: 'value6'
});

alert.addInput({
  type: 'checkbox',
  label: 'Naboo',
  value: 'value6'
});

alert.addInput({
  type: 'checkbox',
  label: 'Takodana',
  value: 'value6'
});

alert.addInput({
  type: 'checkbox',
  label: 'Tatooine',
  value: 'value6'
});

alert.addButton('Cancel');
alert.addButton({
  text: 'Okay',
  handler: data => {
    console.log('Checkbox data:', data);
    this.testCheckboxOpen = false;
    this.testCheckboxResult = data;
  }
});
alert.present().then(() => {
  this.testCheckboxOpen = true;
});

}
}

my values are from server… for example, courses

     this.schoolAppUsers.loadCourses().subscribe(courses =>{
              this.courses = courses;
            }

… how do I loop though courses and assign them to value accordingly
and can somone explain that last part of the example:

         this.testCheckboxOpen = false;
         this.testCheckboxResult = data;

        alert.present().then(() => {
            this.testCheckboxOpen = true;
          });

… can someone help , thanx

1 Like