繁体   English   中英

关闭按钮上的primeng p对话框更改URL-角度2

[英]primeng p-dialog change URL on close button - angular 2

按照Primeng关闭按钮html,href指向#

<a *ngIf="closable" [ngClass]="{'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all':true}" href="#" role="button" (click)="close($event)" (mousedown)="onCloseMouseDown($event)">
                    <span class="fa fa-fw fa-close"></span>
</a>

我的代码是:

<p-dialog header="Student Confirmation" modal="true" appendTo="body" [resizable]="false">

如何将默认href从“#”更改为其他角度?

尝试以下解决方案,但不适用于我:

 public close(): void {
        this.router.navigateByUrl("../studentAssignments", { relativeTo: this.route });
        super.close();
    }

我认为这是不可能的,因为这是primeng组件的默认HTML。

在这种情况下,您可以执行以下操作:可以在对话框组件上调用onHide函数,然后重定向到您想要的任何位置

<p-dialog (onHide)="close()" header="Student Confirmation" modal="true" appendTo="body" [resizable]="false">

public close(): void {
        this.router.navigateByUrl("../studentAssignments", { relativeTo: this.route });
    }

工作实例

从代码中删除href="#"

要么

添加href="javascript:void(0)"

暂无
暂无

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

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