lets say I have admin that wants to register some courses for a particular student , I have followed a way in order to list check boxes that can be multiply selected.
here is the code:
constructor(public schooAppUsers: SchooAppUsers) {
schoolAppUsers.loadAllCourses().subscribe(response => {
this.response = response;
}
// Action sheet code that displays a button and calls {
this.addSelectedCourse();
}
addSelectedCourse(){
let options = this.response;
let select = {
title: 'My Select',
inputs: [],
multiple: true,
buttons: [{
text: 'ok',
handler: data => {
}
}]
}
for (var i=0; i<options.length; i++)
{
select.inputs.push({name: 'myInputs', label: options[i].CourseName, value: options[i].CourseID, type: 'checkbox'});
}
let newAlert = this.alertCtrl.create(select);
newAlert.present();
}
Issue[1]: the service loadAllCourse(), lists all courses in the data base, however, the student might already be registered to some courses, how do I exclude those courses/options from displaying.
Issue[2]: how to store the data back to the server , this is what I’m doing but it displays the alert in every loop and I’m failing to find a work around this. this is inside handler: data {}
for (let course of data){
this.schoolAppUsers.insertStudentCourse(this.UserID, course).subscribe(res => {
let alert = this.alertCtrl.create({
message: res[0].message,
buttons: [{
text: 'Ok',
handler: () =>{
let navTransition = alert.dismiss();
navTransition.then(() => {
this.navCtrl.pop();
});
return false;
}
}]
});
alert.present();
})
}