Looping through and setting label and value of Alert


#1

I am trying to loop through data from server and assign them to label and value , but with no luck…I get an empty object , only the Title and buttons are shown in the alert , can someone help!!

          addValues(){
              let alert = this.alertCtrl.create();
              alert.setTitle('List of Courses');

             this.schoolAppUsers.loadCourses().subscribe(courses => {
               for (let course of courses[0]){
   
                 alert.addInput({
                 type: 'checkbox',
                 label: course.CourseName,
                 value: course.CourseID
                });
             }
           })
           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;
             });
         }