Skip to main content
Edited content.
Source Link
nyedidikeke
  • 7.4k
  • 8
  • 47
  • 61

In Ionic 4, I would like to pass data from Popover controller to the view page. 

I am able to get the data onDismiss()onDismiss() but I would like to do it without exiting the popover. 

Below is the code snippet I tried onDismissonDismiss() and it worked. 

Do we any other popover methods or state changes that can be captured

Page

Page

async presentPopover(opts) {
    
    console.log(opts);
    const popover = await this.popoverController.create({
      component: RouteDetailsPopoverComponent,
      componentProps: {
        viewType: this.viewType
      },
      event: opts.event
    });

    popover.onDidDismiss()
    .then((result) => {
      console.log(result['data']);
      this.viewType = result['data'];
    });

    return await popover.present();
}

And here's the popover component

changeRouteDetailView(mode: View) {
    this.viewType = mode;
    this.popCtrl.dismiss(this.viewType);
}

Without dismissing the popover, can I pass the data back?

In Ionic 4, I would like to pass data from Popover controller to the view page. I am able to get the data onDismiss() but I would like to do it without exiting the popover. Below is the code snippet I tried onDismiss and it worked. Do we any other popover methods or state changes that can be captured

Page

async presentPopover(opts) {
    
    console.log(opts);
    const popover = await this.popoverController.create({
      component: RouteDetailsPopoverComponent,
      componentProps: {
        viewType: this.viewType
      },
      event: opts.event
    });

    popover.onDidDismiss()
    .then((result) => {
      console.log(result['data']);
      this.viewType = result['data'];
    });

    return await popover.present();
}

And here's the popover component

changeRouteDetailView(mode: View) {
    this.viewType = mode;
    this.popCtrl.dismiss(this.viewType);
}

Without dismissing the popover, can I pass the data back?

In Ionic 4, I would like to pass data from Popover controller to the view page. 

I am able to get the data onDismiss() but I would like to do it without exiting the popover. 

Below is the code snippet I tried onDismiss() and it worked. 

Do we any other popover methods or state changes that can be captured

Page

async presentPopover(opts) {
    
    console.log(opts);
    const popover = await this.popoverController.create({
      component: RouteDetailsPopoverComponent,
      componentProps: {
        viewType: this.viewType
      },
      event: opts.event
    });

    popover.onDidDismiss()
    .then((result) => {
      console.log(result['data']);
      this.viewType = result['data'];
    });

    return await popover.present();
}

And here's the popover component

changeRouteDetailView(mode: View) {
    this.viewType = mode;
    this.popCtrl.dismiss(this.viewType);
}

Without dismissing the popover, can I pass the data back?

In Ionic 4, I would like to pass data from Popover controller to the view page. I am able to get the data onDismiss() but I would like to do it without exiting the popover. Below is the code snippet I tried onDismiss and it worked. Do we any other popover methods or state changes that can be captured

Page

Page

async presentPopover(opts) {
    
    console.log(opts);
    const popover = await this.popoverController.create({
      component: RouteDetailsPopoverComponent,
      componentProps: {
        viewType: this.viewType
      },
      event: opts.event
    });

    popover.onDidDismiss()
    .then((result) => {
      console.log(result['data']);
      this.viewType = result['data'];
    });

    return await popover.present();
}

}

And here's the popover component

changeRouteDetailView(mode: View) {
    this.viewType = mode;
    this.popCtrl.dismiss(this.viewType);
}

}

Without dismissing the popover, can I pass the data back?

In Ionic 4, I would like to pass data from Popover controller to the view page. I am able to get the data onDismiss() but I would like to do it without exiting the popover. Below is the code snippet I tried onDismiss and it worked. Do we any other popover methods or state changes that can be captured

Page

async presentPopover(opts) {

console.log(opts);
const popover = await this.popoverController.create({
  component: RouteDetailsPopoverComponent,
  componentProps: {
    viewType: this.viewType
  },
  event: opts.event
});

popover.onDidDismiss()
.then((result) => {
  console.log(result['data']);
  this.viewType = result['data'];
});

return await popover.present();

}

And here's the popover component

changeRouteDetailView(mode: View) {
this.viewType = mode;
this.popCtrl.dismiss(this.viewType);

}

Without dismissing the popover, can I pass the data back?

In Ionic 4, I would like to pass data from Popover controller to the view page. I am able to get the data onDismiss() but I would like to do it without exiting the popover. Below is the code snippet I tried onDismiss and it worked. Do we any other popover methods or state changes that can be captured

Page

async presentPopover(opts) {
    
    console.log(opts);
    const popover = await this.popoverController.create({
      component: RouteDetailsPopoverComponent,
      componentProps: {
        viewType: this.viewType
      },
      event: opts.event
    });

    popover.onDidDismiss()
    .then((result) => {
      console.log(result['data']);
      this.viewType = result['data'];
    });

    return await popover.present();
}

And here's the popover component

changeRouteDetailView(mode: View) {
    this.viewType = mode;
    this.popCtrl.dismiss(this.viewType);
}

Without dismissing the popover, can I pass the data back?

Source Link
PKS
  • 131
  • 1
  • 1
  • 4

Ionic 4 - Pass Data BACK from Popover without dismissing

In Ionic 4, I would like to pass data from Popover controller to the view page. I am able to get the data onDismiss() but I would like to do it without exiting the popover. Below is the code snippet I tried onDismiss and it worked. Do we any other popover methods or state changes that can be captured

Page

async presentPopover(opts) {

console.log(opts);
const popover = await this.popoverController.create({
  component: RouteDetailsPopoverComponent,
  componentProps: {
    viewType: this.viewType
  },
  event: opts.event
});

popover.onDidDismiss()
.then((result) => {
  console.log(result['data']);
  this.viewType = result['data'];
});

return await popover.present();

}

And here's the popover component

changeRouteDetailView(mode: View) {
this.viewType = mode;
this.popCtrl.dismiss(this.viewType);

}

Without dismissing the popover, can I pass the data back?