To explain simply, I have a modal which should open when user navigates to t/:tId/p/:pId or p/:pId to display item details. This modal should be avaliable when user clicks item on homepage or other parts of application. Also it should open when user types localhost:4200/p/:pId on browser url input. The scenario is like instagram post, or beta reddit posts. When user clicks post, it opens modal without destroying page under it.
Edit: Also I don't want to use auxulary routes.
The problem is I cannot open modal without preserving root router state.
Here's what I tried.
Divided root router to two outlets. But It throws url not match error when user navigates to p/:pId.
{
outlet: 'post-root',
path: 'p/:id',
component: PostComponent,
},
{
path: '',
loadChildren: () => import('./root-router/root.module').then(m => m.RootModule)
},
<router-outlet></router-outlet>
<router-outlet name="post-root"></router-outlet>
Second Attempt: Using this route structure:
{
outlet: 'post-root',
path: '',
component: PostComponent,
},
{
path: '',
loadChildren: () => import('./root-router/root.module').then(m => m.RootModule)
},
Both RootModule and PostComponent activates but when t/:tId/p/:pId path hits, I could not manage to make RootModule ignore t/:tId/p/:pId.