0
Follow
0
View

How to route to error page without leaving the current page in Angular

flashgirl_xm 注册会员
2023-01-25 23:01

I recommend you to use the dialog from Angular Material

Imports:

import { MatDialog } from '@angular/material'; 

Constructor:

constructor(
  private dialog: MatDialog,
) { }

Function to display the dialog:

error() {
 const dialogRef = this.dialog.open(CustomErrorHandler, {
   width: '70%', // Make this as big as you want
   data: { error: this.errorType } //Put here the data you want to display one the error page. If you dont need it just delete the line and the ,
 });
}

You can find more info here

About the Author

Question Info

Publish Time
2023-01-25 23:01
Update Time
2023-01-25 23:01