繁体   English   中英

重定向后如何关闭引导程序 angular 模态?

[英]How to close bootstrap angular modal after redirect?

导航到页面后,我试图关闭 boostrap 模式。 但是,当我导航到页面时,模式保持打开状态。 我尝试使用 activeModal class 中的关闭方法,但仍保持打开状态。 这是我的代码:

  viewNewLocationPage(): void {
    this.router.navigate(['/locations/new']);
    this.activeModal.close();
  }

在导航之前关闭模式? 导航会立即发生,因此之后的代码不会执行。 或订阅导航事件并在事件时关闭它。

  viewNewLocationPage(): void {
    this.activeModal.close();
    this.router.navigate(['/locations/new']); 
  }

你可以尝试这样做:

this.router.navigate(['/locations/new']).then(() => this.activeModal.close());

您可以将按钮更改为 html 中的链接标记。

例如。

<a [routerLink]="['/home']" class="btn btn-outline-dark" (click)="d('Save click')">Payment</a>

Thia 将重定向并关闭模态。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM