我有一个标准的Ionic 4页面(主页),该页面创建一个使用组件(BusinessDetails)和一个按钮的弹出窗口,该按钮重定向到新页面(RequestTurn)。但是,当我单击该按钮时,弹出窗口不会消失,而是呈现在我的RequestTurn页面顶部。我想我需要从组件(BusinessDetails)中手动关闭它,但是我不知道如何从那里访问弹出窗口的实例,因为它是在主页中创建的。有没有办法做到这一点?
home.page.ts
presentModal(business:Business, event: Event) {
this.popoverController.create(({
component: BusinessDetailsComponent,
cssClass: "business-popover",
showBackdrop: true,
componentProps: {
business: business
}
}) as any).then(popover => popover.present()); }
Run Code Online (Sandbox Code Playgroud)
business-detail.component.ts
goToRequestTurn(id: string) {
//Need to dismiss popver here (?)
this.router.navigateByUrl(`/request-turn/${id}`); }
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助。
小智 15
添加 private popoverController: PopoverController到组件构造函数
然后编写一个这样的函数,并在您希望消除模态时调用它
async DismissClick() {
await this.popoverController.dismiss();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3193 次 |
| 最近记录: |