gpt4 book ai didi

angular - Ionic 4 - 从 Popover 传回数据而不关闭

转载 作者:太空狗 更新时间:2023-10-29 18:28:29 27 4
gpt4 key购买 nike

在 Ionic 4 中,我想将数据从 Popover Controller 传递到 View 页面。

我能够获取数据 onDismiss() 但我想在不退出弹出窗口的情况下执行此操作。

下面是我试过 onDismiss() 的代码片段,它起作用了。

我们是否有任何其他可以捕获的弹出方法或状态变化

页面

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();
}

这是弹出组件

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

在不关闭弹出窗口的情况下,我可以传回数据吗?

最佳答案

在调用弹出窗口组件的页面中,在“create()”和“present()”方法后键入此内容以使用弹出窗口:

const { data } = await popover.onDidDismiss();

'data' 将存储您从 popover 组件发送的值到您调用 popover 组件的页面中。

同时,在popover组件中需要向页面发送数据。在您需要从弹出窗口返回的方法中使用此行代码:

this.popoverCtrl.dismiss({ data_you_sent });

method , dismiss(), 返回数据(如果你发送了)并关闭弹出窗口。

关于angular - Ionic 4 - 从 Popover 传回数据而不关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53489846/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com