我在模态内给出了链接,单击该链接将在另一页上进行。当链接打开另一个页面时,模态不会关闭,所以我需要帮助来关闭模态。
× 重要的提示我们强烈建议您进行个人预订。
继续作为情侣...答案 0 :(得分:0)
假设您的模式中有如下代码段
in component.html
<a (click)="goToNextPage()" >click here</a>
并在component.ts
文件中添加以下代码
在 component.ts
constructor(
private router:Router,
public dialogRef: MatDialogRef<ModalComponent> //replace your modal component here,
) { }
goToNextPage(){
this.dialogRef.close();
this.router.navigate(['/nextPageURL']);
}
为了更好地理解,请检查official doc