PKS*_*PKS 13 popover angular ionic4
在 Ionic 4 中,我想将数据从 Popover 控制器传递到视图页面。
我能够获取数据,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();
}
Run Code Online (Sandbox Code Playgroud)
这是弹出组件
changeRouteDetailView(mode: View) {
this.viewType = mode;
this.popCtrl.dismiss(this.viewType);
}
Run Code Online (Sandbox Code Playgroud)
在不关闭弹出窗口的情况下,我可以将数据传回吗?
小智 6
在调用弹出窗口组件的页面中,在“create()”和“present()”方法之后键入以下内容以使用弹出窗口:
const { data } = await popover.onDidDismiss();
Run Code Online (Sandbox Code Playgroud)
'data' 将存储您从弹出组件发送的值到您称为弹出组件的页面中。
同时,在popover组件中你需要将数据发送到页面。在您需要从弹出窗口返回的方法中使用此行代码:
this.popoverCtrl.dismiss({ data_you_sent });
Run Code Online (Sandbox Code Playgroud)
此方法,miss(),返回数据(如果您发送了)并关闭弹出窗口。
| 归档时间: |
|
| 查看次数: |
8121 次 |
| 最近记录: |