I am unable to make it work. The popup calling code is
presentPopover(myEvent){
//alert('invoke popup')
let popover = this.popoverCtrl.create(PopoverPage, this.data);
popover.present(
{
ev: myEvent
}
);
}
and the part where i need to access currently is:
export class PopoverPage{
constructor(public viewCtrl: ViewController) {
// alert('in the popup')
//alert(this.data)
}
So how will the data be avaialbe in the popupover page component ?
Parameters/data can be passed to the Popover like this
let popover = this.popoverCtrl.create(PopoverPage, {key1:value1, key2: value2});
And then you can use NavParams
to retrieve the data passed to the Popover.
export class PopoverPage{
constructor(public navParams:NavParams) {
console.log(this.navParams.data);
let value1 = this.navParams.get('key1');
let value2 = this.navParams.get('key2');
}
}
For ionic v4, you can send data using componentProps
to pass data and retrieve through navParams.
const popover = await this.popoverController.create({
component: PopoverPage,
componentProps:{key1:value1, key2: value2}
});
return await popover.present()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With