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

Angular 启动关闭按钮上的p对话框更改URL-角度2,angular,primeng,Angular,Primeng,根据Priming close按钮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)"> <

根据Priming close按钮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>
从代码中删除href=


Add href=javascript:void0

我认为这是不可能的,因为这是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=javascript:void0 click=close而不是href=click=close$事件?这对您有用吗???这是预充本身带来的,无法更改此html文件您是否也可以尝试此操作:onAfterHide=close这将在关闭事件后触发。正在调用close,但它没有使用下面的代码导航到URL。this.router.navigateByUrl../studentAssignments,{relativeTo:this.route};这是素描本身附带的href,除非您对库本身进行了更改,否则无法手动更改。那么我可以更改行为吗?还是图标fa fa close?你知道吗,帕迪普?试过这个,但没用。router.navigateByUrl../studentAssignments,{relativeTo:this.route};这应该行得通,我试过我的本地电脑。请检查关闭时您的函数是否正在调用?@VaibhavSawant请检查我的更新答案和工作示例
 public close(): void {
        this.router.navigateByUrl("../studentAssignments", { relativeTo: this.route });
        super.close();
    }
<p-dialog (onHide)="close()" header="Student Confirmation" modal="true" appendTo="body" [resizable]="false">

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