Hello!
What I wanted to do was to open a mat-dialog by clicking on an icon. This mat-dialog is a split panel that has to the left side buttons that can be clicked and to the right side a content space where other components are supposed to be loaded on click on the specific button. Now, I followed the guidelines of the original documentation for routing on https://angular.io/guide/router , but when I clicked the first icon to open the dialog, it's style was changed and it didn't open in form of a dialog anymore. Now I figured I could just keep the dialog style by changing the url within the method of calling the dialog like this
dialogRef.afterOpened().subscribe(result => {
this.router.navigate(['/dialog']);
});
dialogRef.afterClosed().subscribe(result => {
this.router.navigate(['']);
});
Like this the url changed with opening anf closing the dialog the way I wanted. But I've got another routing-module with another component, which is working perfectly fine, before opening the dialog,but does not work anymore afterwards. And now the loading of the component via routing and using 'router-outlet' in the html tag does not work either. Now, my question is if there are some general problems with mat-dialog and routing that I might solve by using a different way?
Is it necassary to code a custom dialog (not using mat-dialog)?
I had everything working fine before with a service, though I thought changing the url and opening the components by navigation would be a lot less code and a nicer solution.
Hopefully, someone can explain this problem to me and what is actually happening. I might provide more general code, but like I said I pretty much followed the official documentation. Thanks in advance!
Hi jb,
dialogRef.afterOpened().subscribe(result => { this.router.navigate(['/dialog']); });
Would that not destroy the dialog, as it is alraedy inside the router-outlet you care now moving away from?
If that’s not the case, can you build a StackBlitz to show your issue?
Regards
Sander