Am new to ionic, and am currently stuck in this problem, I'm trying to pass an object that have this structure
{
car: {...}
reservations:[{...},{...},...]
}
I did this code but a was able to send only the car object but couldnt send the reservation array.
page1 (sender):
//class success object
class SuccessObject {
success: any;
public constructor(success: any) {
this.success = success;
}
}
public getCar(id){
let loader = this.loading.get('Chargement de la reservation...');
loader.present();
this.data.getCar(id).subscribe(
data => {
//DATA is full with car infos and its reservations
let infos: SuccessObject = new SuccessObject(data);
this.navCtrl.push(CarinfosPage, {
'car': infos.success.car,
'res': infos.success.reservation,
});
loader.dismiss();
},
err => {
loader.dismiss();
}
);
}
page 2 (reciever):
export class CarinfosPage {
public data;
reservations = <any>{};
car = <any>{};
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.reservations = this.navParams.data;
this.car = this.navParams.get('car');
}
ionViewDidLoad() {
console.log(this.car); // i get car infos here
console.log(this.reservations); // i get undefined here
}
}